MCPcopy
hub / github.com/wal-g/wal-g / PutObject

Method PutObject

pkg/storages/fs/folder.go:101–121  ·  view source on GitHub ↗
(name string, content io.Reader)

Source from the content-addressed store, hash-verified

99}
100
101func (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
123func (folder *Folder) PutObjectWithContext(ctx context.Context, name string, content io.Reader) error {
124 ctxReader := contextio.NewReader(ctx, content)

Callers 2

PutObjectWithContextMethod · 0.95
CopyObjectMethod · 0.95

Calls 5

GetFilePathMethod · 0.95
OpenFileWithDirFunction · 0.85
ErrorfMethod · 0.80
PrintlnMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected