Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download a file from AWS S3 with version in Command line?

I have created an AWS S3 bucket with versioning and created a file with multiple versions. Is there any way I could download a file with a particular version using command line or API?

like image 860
Balasekhar Nelli Avatar asked Nov 10 '15 06:11

Balasekhar Nelli


People also ask

How do I download data from aws S3?

In the Amazon S3 console, choose your S3 bucket, choose the file that you want to open or download, choose Actions, and then choose Open or Download. If you are downloading an object, specify where you want to save it.


2 Answers

To list out a particular file version use below command and you will get ObjectVersionId

aws s3api list-object-versions --bucket bucketname --prefix  folder/test/default.json --output json

ObjectVersionId:"Cu9ksraX_OOpbAtobdlYuNPCoJFY4N3S"

aws s3api get-object --bucket bucketname --key folder/test/default.json D:/verions/default.json --version-id Cu9ksraX_OOpbAtobdlYuNPCoJFY4N3S
like image 185
Raju Avatar answered Oct 14 '22 00:10

Raju


Via command line:

aws s3api get-object --version-id ...

To first get a list of the available versions:

aws s3api list-object-versions ...

There are similar methods in the respective AWS SDKs.

like image 38
Mark B Avatar answered Oct 14 '22 00:10

Mark B