Is there any way to see the date on which an image was taken in Next.JS
Unanswered
elbeenmachine posted this in #help-forum
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?
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?
9 Replies
Asian black bear
You need a library to read the metadata from photos. It would probably sit in your stack around where the actual photo data is copied into the presigned URL.
If you don't mind the cruft,
sharp will let you do this. There may be other lighter libraries that do not include the image editing/binary partsI usually use sharp, but I was unable to get it working inside Next
Asian black bear
What would you be using sharp for in next when you are doing this?
I am using presigned URLs to upload the images to S3, as uploading 4K images through serverless functions is an absolute no-go.I think the "proper" way to handle the metatdata would be to read it once during load from the image files and somehow store it in your database alongside the filename.
When creating the signed url and/post policy for your image
You can read the meta data of the file and send that as part of the request
Before the image is actually uploaded to the signed url
Check out the next-upload package which streamlines this entire process