-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: optional --range argument for cp to download single part of object #772
base: master
Are you sure you want to change the base?
feat: optional --range argument for cp to download single part of object #772
Conversation
@@ -620,6 +621,9 @@ func (s *S3) Get( | |||
if from.VersionID != "" { | |||
input.VersionId = aws.String(from.VersionID) | |||
} | |||
if contentRange != nil { | |||
input.Range = aws.String(*contentRange) | |||
} | |||
|
|||
return s.downloader.DownloadWithContext(ctx, to, input, func(u *s3manager.Downloader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think I should use the Download()
function from your screenshot instead of s.downloader.DownloadWithContext(...)
? Since it does the same thing as the code in line 624 of s3.go?
Adds an optional string argument
--range
tocp
command, which exposes the existing AWS GetObject Range header to provide a specific byterange of the object to be copied.Now s5cmd users can optionally set this header manually and only download a specific part of their src object.
Example:
Obviously makes any
--concurrency
or--part_size
arguments redundant when--range
is specified, since only 1 part will be downloaded, using only 1 thread.Note: AWS GetObject only supports specifying a single byte range, so we are also constrained by this limitation. An s5cmd user would have to run multiple
cp
commands to download, for example, bytes ranging from 100-199 (bytes=100-199
) and from 300-399 (bytes=300-399
).Solves this Issue: #756