Skip to content
This repository has been archived by the owner on Oct 15, 2021. It is now read-only.

Support offset and size for read #157

Merged
merged 4 commits into from
Jul 22, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@ func (s *Storage) read(ctx context.Context, path string, w io.Writer, opt pairSt
Bucket: aws.String(s.name),
Key: aws.String(rp),
}
if opt.Size > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use opt.HasXxxx to check size and offset.

It's OK to eliminate the check for offset, but please fill comments here for the reason.

Copy link
Contributor Author

@zhaohuxing zhaohuxing Jul 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified, Please Review.

input.Range = aws.String(fmt.Sprintf("bytes=%d-%d", opt.Offset, opt.Offset+opt.Size-1))
}
if opt.HasExceptedBucketOwner {
input.ExpectedBucketOwner = &opt.ExceptedBucketOwner
}
Expand Down