diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2018-04-29 21:19:14 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2018-04-30 10:04:36 +0200 |
| commit | 0df55a731aa3330f82d22b010a7a2a4d66521972 (patch) | |
| tree | 9e207f01dbb52afb0de83f95e63ecfc771e809c6 /object.go | |
| parent | 1f3fcfa9366e49b371c7be2b5c90b957ce93b8dd (diff) | |
| download | go-schwift-0df55a731aa3330f82d22b010a7a2a4d66521972.tar.gz | |
initial support for large objects
This has gone through a lot of iterations on my branch, and I'm quite
happy with the parts of the API that exist now. Test coverage can still
be better, and will get better in the following commits.
The API is not yet finished: I want to add Options arguments to
Object.Upload(), Object.Copy(), Object.Move() and Object.Delete() that
specify how each of these operations affect existing segments (and,
later, also existing symlinks). For Upload(), uploading in segments
shall become as easy as flipping a single switch.
Diffstat (limited to 'object.go')
| -rw-r--r-- | object.go | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -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) + } } } |
