aboutsummaryrefslogtreecommitdiff
path: root/object.go
diff options
context:
space:
mode:
Diffstat (limited to 'object.go')
-rw-r--r--object.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/object.go b/object.go
index 8ef314a..4ff1f4f 100644
--- a/object.go
+++ b/object.go
@@ -167,15 +167,23 @@ func (o *Object) Update(headers ObjectHeaders, opts *RequestOptions) error {
func (o *Object) Upload(content io.Reader, opts *RequestOptions) error {
opts = cloneRequestOptions(opts, nil)
hdr := ObjectHeaders{opts.Headers}
- tryComputeContentLength(content, hdr)
- tryComputeEtag(content, hdr)
- //could not compute Etag in advance -> need to check on the fly
+ //do not attempt to add the Etag header when we're writing a large object
+ //manifest; the header refers to the content, but we would be computing the
+ //manifest's hash instead
+ isManifestUpload := opts.Values.Get("multipart-manifest") == "put" || hdr.IsDynamicLargeObject()
+
var hasher hash.Hash
- if !hdr.Etag().Exists() {
- hasher = md5.New()
- if content != nil {
- content = io.TeeReader(content, hasher)
+ tryComputeContentLength(content, hdr)
+ if !isManifestUpload {
+ tryComputeEtag(content, hdr)
+
+ //could not compute Etag in advance -> need to check on the fly
+ if !hdr.Etag().Exists() {
+ hasher = md5.New()
+ if content != nil {
+ content = io.TeeReader(content, hasher)
+ }
}
}