diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2018-09-12 15:07:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-12 15:07:33 +0200 |
commit | fba0f8e8b2e869654b3970396ed6fb0647e8910f (patch) | |
tree | 8e97584f48db32d244e7c061a5ac859f414c95dc /utils/file_backend_s3.go | |
parent | e32581aef3253bb0691d6fd678fbf01e86f2c10c (diff) | |
parent | 7d60bc8cf57b9e47ad4d07bc4bbf61ee2f23c457 (diff) | |
download | chat-fba0f8e8b2e869654b3970396ed6fb0647e8910f.tar.gz chat-fba0f8e8b2e869654b3970396ed6fb0647e8910f.tar.bz2 chat-fba0f8e8b2e869654b3970396ed6fb0647e8910f.zip |
Merge release-5.3
Diffstat (limited to 'utils/file_backend_s3.go')
-rw-r--r-- | utils/file_backend_s3.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/utils/file_backend_s3.go b/utils/file_backend_s3.go index 2868dd342..f5f96f878 100644 --- a/utils/file_backend_s3.go +++ b/utils/file_backend_s3.go @@ -4,6 +4,7 @@ package utils import ( + "bytes" "io" "io/ioutil" "net/http" @@ -182,7 +183,12 @@ func (b *S3FileBackend) WriteFile(fr io.Reader, path string) (int64, *model.AppE } options := s3PutOptions(b.encrypt, contentType) - written, err := s3Clnt.PutObject(b.bucket, path, fr, -1, options) + var buf bytes.Buffer + _, err = buf.ReadFrom(fr) + if err != nil { + return 0, model.NewAppError("WriteFile", "api.file.write_file.s3.app_error", nil, err.Error(), http.StatusInternalServerError) + } + written, err := s3Clnt.PutObject(b.bucket, path, &buf, int64(buf.Len()), options) if err != nil { return written, model.NewAppError("WriteFile", "api.file.write_file.s3.app_error", nil, err.Error(), http.StatusInternalServerError) } |