I'm creating a photo gallery application using Next.JS, AWS S3, ImageKit and MongoDB. For a bit of context, I already had a photo-gallery app made, but it relied on an external express.js API that I was hosting on a VPS, which seemed a bit unnecessary and overcomplicated for my use-case.
So far, it is going really well, but I've hit a bit of a roadblock.
I am using presigned URLs to upload the images to S3, as uploading 4K images through serverless functions is an absolute no-go. But I cannot access the same properties that I could when I was uploading through express.
I can see the date on which a photo was last modified, but that is not very useful, especially when an image has been copied from a network drive or downloaded from Google Drive or OneDrive.
Is there any way that I could access the date on which a file (in this case an image) was created/taken without the use of an external API as I was doing beforehand?
You can always use the
statfunction that is found in the NodeJS Filsystem API (fs), note that there’s also abirthtimeMsproperty in the stats object holding the file’s created date in milliseconds: