(name string, content io.Reader)
| 99 | } |
| 100 | |
| 101 | func (folder *Folder) PutObject(name string, content io.Reader) error { |
| 102 | tracelog.DebugLogger.Printf("Put %v into %v\n", name, folder.subPath) |
| 103 | filePath := folder.GetFilePath(name) |
| 104 | file, err := OpenFileWithDir(filePath) |
| 105 | if err != nil { |
| 106 | return fmt.Errorf("unable to open file %q: %w", filePath, err) |
| 107 | } |
| 108 | _, err = io.Copy(file, content) |
| 109 | if err != nil { |
| 110 | closerErr := file.Close() |
| 111 | if closerErr != nil { |
| 112 | tracelog.InfoLogger.Println("Error during closing failed upload ", closerErr) |
| 113 | } |
| 114 | return fmt.Errorf("unable to copy data to file %q: %w", filePath, err) |
| 115 | } |
| 116 | err = file.Close() |
| 117 | if err != nil { |
| 118 | return fmt.Errorf("unable to close file %q: %w", filePath, err) |
| 119 | } |
| 120 | return nil |
| 121 | } |
| 122 | |
| 123 | func (folder *Folder) PutObjectWithContext(ctx context.Context, name string, content io.Reader) error { |
| 124 | ctxReader := contextio.NewReader(ctx, content) |
no test coverage detected