Reputation: 2886
Trying to download an older version of a file using boto3. I currently have this to download the latest version and this works.
get_obj = s3.download_file(
Bucket="my_bucket",
Key="testfile.txt",
Filename='myfile'
)
However I want to grab a previous version of the file and going thru the docs I see that download_object
does allow extra args . More docs here
So I changed my code to this:
data = {'VersionId': prev_ver_id}
get_obj = s3.download_file(
Bucket="my_bucket",
Key="testfile.txt",
Filename='myfile',
**data)
However this keeps throwing TypeError: download_file() got an unexpected keyword argument 'VersionId'
Im not sure what Im missing here.
Upvotes: 1
Views: 2913
Reputation: 363314
You have to pass the extra args in a dict:
response = s3.download_file(
Bucket="my_bucket",
Key="testfile.txt",
Filename='myfile',
ExtraArgs={'VersionId': prev_ver_id},
)
Upvotes: 4