Update the already existing object Copy the reader into the object updating modTime and size. The new object may have been created if an error is returned
(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption)
| 1134 | // |
| 1135 | // The new object may have been created if an error is returned |
| 1136 | func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error { |
| 1137 | in1 := readers.NewCountingReader(in) |
| 1138 | modTime := src.ModTime(ctx) |
| 1139 | remote := o.filePath() |
| 1140 | |
| 1141 | //create full path to file before upload. |
| 1142 | err := o.fs.mkParentDirs(ctx, remote) |
| 1143 | if err != nil { |
| 1144 | return err |
| 1145 | } |
| 1146 | |
| 1147 | //upload file |
| 1148 | err = o.upload(ctx, in1, true, fs.MimeType(ctx, src), options...) |
| 1149 | if err != nil { |
| 1150 | return err |
| 1151 | } |
| 1152 | |
| 1153 | //if file uploaded successfully then return metadata |
| 1154 | o.modTime = modTime |
| 1155 | o.md5sum = "" // according to unit tests after put the md5 is empty. |
| 1156 | o.size = int64(in1.BytesRead()) // better solution o.readMetaData() ? |
| 1157 | //and set modTime of uploaded file |
| 1158 | err = o.SetModTime(ctx, modTime) |
| 1159 | |
| 1160 | return err |
| 1161 | } |
| 1162 | |
| 1163 | // Remove an object |
| 1164 | func (o *Object) Remove(ctx context.Context) error { |
nothing calls this directly
no test coverage detected