objectstorage s3: use limitreader in write object

If size is specified limit reads to size bytes.
This commit is contained in:
Simone Gotti 2019-10-25 10:06:22 +02:00
parent 3808c71b37
commit 0388003d09
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
} }