Skip to content

Commit

Permalink
objectstorage s3: use limitreader in write object
Browse files Browse the repository at this point in the history
If size is specified limit reads to size bytes.
  • Loading branch information
sgotti committed Oct 25, 2019
1 parent 5d6ebf0 commit 5f119d0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/objectstorage/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// then put it. See commented out code below.
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
}

Expand Down

0 comments on commit 5f119d0

Please sign in to comment.