Update the object with the contents of the io.Reader, 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)
| 649 | // |
| 650 | // The new object may have been created if an error is returned |
| 651 | func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error) { |
| 652 | bucket, bucketPath := o.split() |
| 653 | var data []byte |
| 654 | var size int64 |
| 655 | var hash string |
| 656 | if o.fs.opt.Discard { |
| 657 | h := md5.New() |
| 658 | size, err = io.Copy(h, in) |
| 659 | hash = hex.EncodeToString(h.Sum(nil)) |
| 660 | } else { |
| 661 | data, err = io.ReadAll(in) |
| 662 | size = int64(len(data)) |
| 663 | } |
| 664 | if err != nil { |
| 665 | return fmt.Errorf("failed to update memory object: %w", err) |
| 666 | } |
| 667 | o.od = &objectData{ |
| 668 | data: data, |
| 669 | size: size, |
| 670 | hash: hash, |
| 671 | modTime: src.ModTime(ctx), |
| 672 | mimeType: fs.MimeType(ctx, src), |
| 673 | } |
| 674 | buckets.updateObjectData(bucket, bucketPath, o.od) |
| 675 | return nil |
| 676 | } |
| 677 | |
| 678 | // Remove an object |
| 679 | func (o *Object) Remove(ctx context.Context) error { |
no test coverage detected