Skip to content

Commit 8e3a72e

Browse files
add accept header gzip to avoid the transport client from decompresing gzip files when syncing files (larrabee#80)
Co-authored-by: Boris Smidt <[email protected]>
1 parent 9c616bb commit 8e3a72e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

storage/s3/s3.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"crypto/tls"
77
"errors"
8+
"github.com/aws/aws-sdk-go/aws/request"
89
"io"
910
"net/http"
1011
"net/url"
@@ -190,6 +191,12 @@ func (st *S3Storage) PutObject(obj *storage.Object) error {
190191
return nil
191192
}
192193

194+
func withAcceptEncoding(e string) request.Option {
195+
return func(r *request.Request) {
196+
r.HTTPRequest.Header.Add("Accept-Encoding", e)
197+
}
198+
}
199+
193200
// GetObjectContent read object content and metadata from S3.
194201
func (st *S3Storage) GetObjectContent(obj *storage.Object) error {
195202
input := &s3.GetObjectInput{
@@ -198,7 +205,7 @@ func (st *S3Storage) GetObjectContent(obj *storage.Object) error {
198205
VersionId: obj.VersionId,
199206
}
200207

201-
result, err := st.awsSvc.GetObjectWithContext(st.ctx, input)
208+
result, err := st.awsSvc.GetObjectWithContext(st.ctx, input, withAcceptEncoding("gzip"))
202209
if err != nil {
203210
return err
204211
}

0 commit comments

Comments
 (0)