Merge pull request #152 from sgotti/objectstorage_s3_use_limitreader

objectstorage s3: use limitreader in write object
This commit is contained in:
Simone Gotti 2019-10-25 12:23:19 +02:00 committed by GitHub
commit 8a32e2251e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -92,7 +92,8 @@ func (s *S3Storage) WriteObject(filepath string, data io.Reader, size int64, per
// An alternative is to write the file locally so we can calculate the size and // An alternative is to write the file locally so we can calculate the size and
// then put it. See commented out code below. // then put it. See commented out code below.
if size >= 0 { if size >= 0 {
_, err := s.minioClient.PutObject(s.bucket, filepath, data, size, minio.PutObjectOptions{ContentType: "application/octet-stream"}) lr := io.LimitReader(data, size)
_, err := s.minioClient.PutObject(s.bucket, filepath, lr, size, minio.PutObjectOptions{ContentType: "application/octet-stream"})
return err return err
} }