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 all 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
8 changes: 8 additions & 0 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,14 @@ 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.HasOffset && opt.HasSize {
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved
input.Range = aws.String(fmt.Sprintf("bytes=%d-%d", opt.Offset, opt.Offset+opt.Size-1))
} else if opt.HasOffset && !opt.HasSize {
input.Range = aws.String(fmt.Sprintf("bytes=%d-", opt.Offset))
} else if !opt.HasOffset && opt.HasSize {
input.Range = aws.String(fmt.Sprintf("bytes=0-%d", opt.Size-1))
}

if opt.HasExceptedBucketOwner {
input.ExpectedBucketOwner = &opt.ExceptedBucketOwner
}
Expand Down