Reputation: 50
I have few files stored in s3 and I have to find out the date when file was exactly created. As soon as I download the file, new created_at
timestamp is generated for the file, but I am able to see correct created_at
timestamp when I open it in excel or pdf.
I am using node.js
for fetching files from s3 and need some library to give these dates to me.
I have already tried xslx
, fs
, winattr
and aws-sdk
.
Upvotes: 0
Views: 3582
Reputation: 2593
For local files, e.g. the files after you've downloaded then you can use the Node JS fs.stat function.
This will give you the file stats/metadata details as they are stored by the OS you're running node.js on.
see https://nodejs.org/api/fs.html#fs_fs_stat_path_callback
If you're looking for the date the file was created on Amazon S3 then you can use the Object HEAD rest request.
See Amazon S3 Object HEAD Documentation for further info on that.
It appears Last-Modified is the last modified or creation date of an object, whichever came last. That might give you the granularity that you need. If not you can probably the HEAD command in combination with the versioning commands to figure out the creation date. Find the first version then get the Last-Modified for that first version for the creation date.
See Amazon S3 Object HEAD Versioning for further details.
PDF files store their access, created and so forth metadata properties internally as part of their format. You can parse those details using https://github.com/Gottox/node-pdfutils
Excel files and most Microsoft documents do something similar, you might be able to read the created property of the workbook using https://www.npmjs.com/package/xlsx
Upvotes: 2