mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 22:27:35 +00:00
s3: enable content hash calculation for uploads
This commit is contained in:
parent
553ea36ca6
commit
ee2f14eaf0
@ -200,6 +200,7 @@ func (be *b2Backend) Save(ctx context.Context, h restic.Handle, rd restic.Rewind
|
|||||||
debug.Log("Save %v, name %v", h, name)
|
debug.Log("Save %v, name %v", h, name)
|
||||||
obj := be.bucket.Object(name)
|
obj := be.bucket.Object(name)
|
||||||
|
|
||||||
|
// b2 always requires sha1 checksums for uploaded file parts
|
||||||
w := obj.NewWriter(ctx)
|
w := obj.NewWriter(ctx)
|
||||||
n, err := io.Copy(w, rd)
|
n, err := io.Copy(w, rd)
|
||||||
debug.Log(" saved %d bytes, err %v", n, err)
|
debug.Log(" saved %d bytes, err %v", n, err)
|
||||||
|
@ -270,6 +270,8 @@ func (be *Backend) Save(ctx context.Context, h restic.Handle, rd restic.RewindRe
|
|||||||
|
|
||||||
opts := minio.PutObjectOptions{StorageClass: be.cfg.StorageClass}
|
opts := minio.PutObjectOptions{StorageClass: be.cfg.StorageClass}
|
||||||
opts.ContentType = "application/octet-stream"
|
opts.ContentType = "application/octet-stream"
|
||||||
|
// the only option with the high-level api is to let the library handle the checksum computation
|
||||||
|
opts.SendContentMd5 = true
|
||||||
|
|
||||||
debug.Log("PutObject(%v, %v, %v)", be.cfg.Bucket, objName, rd.Length())
|
debug.Log("PutObject(%v, %v, %v)", be.cfg.Bucket, objName, rd.Length())
|
||||||
info, err := be.client.PutObject(ctx, be.cfg.Bucket, objName, ioutil.NopCloser(rd), int64(rd.Length()), opts)
|
info, err := be.client.PutObject(ctx, be.cfg.Bucket, objName, ioutil.NopCloser(rd), int64(rd.Length()), opts)
|
||||||
|
Loading…
Reference in New Issue
Block a user