s3-latest
A teeny tiny utility that retrieves the latest item in an Amazon S3 bucket. Designed as a great way to get the most recent backup of something. There are probably other uses.
Using from the command line
- Put
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
in your environment. npm install -g s3-latest
s3-latest --bucket bucketname --before 2013-12-12 | tar -xzv
Using from node.js
var S3Latest = ;var configuration = bucket: 'bucketName' before: "Mon, 02 Dec 2013 00:00:00 GMT" // option 1:; // option 2:;
Options
These can be passed in as command line options or as keys to the configuration object.
--bucket
: S3 bucket name--prefix
: String to search for files with. Needs to be at the beginning of the key. Usually used for s3 folder names.--before
: A date (or amoment.js
-compatible string representation of a date). Returns the latest object in the bucket after this date.
S3 Object details
When using the api with option 2 (see above), you can access the following information about the latest S3 object:
Owner
:{ID: '<< AWS IAM User id>>', DisplayName: '<< AWS IAM Display Name >>'}
Size
: size of the object in bytesETag
: version informationLastModified
: timestampKey
: S3 Key