405 Error with S3 Presigned URL's
I currently have a 'PDF viewer' on my website which is suppose to render a PDF from my s3 bucket and prevent the user from being able to download, print, etc the pdf.
Here's the code for the /exams/page.tsx file (the PDF viewer)
(continued because im running out of characters)
5 Replies
I also have an API in /api/exams with a function to get a presigned URL from S3
/api/exams/route.ts
When I change
to a presigned URL I get directly from S3 console, the PDF works and renders completely fine. However, when I try and get a new presigned URL by calling my api, and then passing that response as oppose to getting a presigned URL from the S3 console, I get the error:
I've made an IAM user with the permissions required and passed in the credentials to those in "accessKeyId" and "secretAccessKey". The bucket name is also correct, and so is the object key. Anyone know how I can fix this?
I also get the following errors in my terminal
as well as a warning to migrate to the AWS SDK (v3) (not sure if the outdated AWS SDK could be causing the issue)
not a ton of aws experience but my guess is this is a permissions thing
you could try generating a new set of credentials with every permission and see if it works then take away one at a time to see what mightve been causing the error
https://link.medium.com/B21i2jAJlAb
Maybe encryption keys with the objects that are at rest
theburningmonk.com
Yes, S3 now encrypts objects by default, but your job is not done y...
Learn to build production-ready serverless applications on AWS
Posting this because when you create a pre signed URL you are in essence sharing the exception key to the user
"Any request through the AWS SDK, AWS CLI or via the public URL of an object would give the attacker access to the unencrypted object contents. S3 would decrypt the data and return the unencrypted data because it owns the encryption keys."
thought it was this too but my IAM user (the one im using to make the api call) has "AmazonS3FullAccess" as part of its permissions
fixed it 👍