Skip to content

Commit

Permalink
Compression: Handle auto encryption when size is unknown (minio#7600)
Browse files Browse the repository at this point in the history
When size is unknown and auto encryption is enabled,
and compression is set to true, putobject API is failing.

Moving adding the SSE-S3 header as part of the request to before
checking if compression can be done, otherwise the size is set to -1
and that seems to cause problems.
  • Loading branch information
kannappanr authored May 2, 2019
1 parent 033f3a4 commit 4b858b5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/object-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,11 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
}
}

// This request header needs to be set prior to setting ObjectOptions
if globalAutoEncryption && !crypto.SSEC.IsRequested(r.Header) {
r.Header.Add(crypto.SSEHeader, crypto.SSEAlgorithmAES256)
}

actualSize := size

if objectAPI.IsCompressionSupported() && isCompressible(r.Header, object) && size > 0 {
Expand Down Expand Up @@ -1205,10 +1210,6 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
rawReader := hashReader
pReader := NewPutObjReader(rawReader, nil, nil)

// This request header needs to be set prior to setting ObjectOptions
if globalAutoEncryption && !crypto.SSEC.IsRequested(r.Header) {
r.Header.Add(crypto.SSEHeader, crypto.SSEAlgorithmAES256)
}
// get gateway encryption options
var opts ObjectOptions
opts, err = putOpts(ctx, r, bucket, object, metadata)
Expand Down

0 comments on commit 4b858b5

Please sign in to comment.