Next.js Discord

Discord Forum

s3 Bucket next

Answered
Red-billed Tropicbird posted this in #help-forum
Open in Discord
Red-billed TropicbirdOP
Hi guys i am using a s3 bucket on aws and am builidng a resume builder application my templates are stored on the bucket as pdfs, I am new to this so how do I retrieve them from the bucket and display them on my app. I am also using neondb with prisma.
Answered by B33fb0n3
you can get them directly from your bucket via the url https://s3.<region>.amazonaws.com/<bucket>/<key>
Either display it directly via a component or let the user download it. But watch out: directly accessing files from your s3 can be expensive. You might want to use a CDN for it. If you want to stay at aws, use cloudfront as cdn and if you want a better alternative use bunnycdn
View full answer

24 Replies

@Red-billed Tropicbird Hi guys i am using a s3 bucket on aws and am builidng a resume builder application my templates are stored on the bucket as pdfs, I am new to this so how do I retrieve them from the bucket and display them on my app. I am also using neondb with prisma.
you can get them directly from your bucket via the url https://s3.<region>.amazonaws.com/<bucket>/<key>
Either display it directly via a component or let the user download it. But watch out: directly accessing files from your s3 can be expensive. You might want to use a CDN for it. If you want to stay at aws, use cloudfront as cdn and if you want a better alternative use bunnycdn
Answer
Red-billed TropicbirdOP
ok
Red-billed TropicbirdOP
@B33fb0n3 for my resume builder app should I save the templates as pdfs or html and css files?
I also went with cloudfront
And would I still be driectly accessing files now?
@Red-billed Tropicbird <@301376057326567425> for my resume builder app should I save the templates as pdfs or html and css files?
I would save them as pdfs. If you need data from them, scan them and extract the data. Then save the extracted data inside a database
@Red-billed Tropicbird And would I still be driectly accessing files now?
That depends on the configuration you made for your bucket and cloudfront. Try accessing them in a incognito tab (inside it you won't have cookies and you are not logged in) and see if you can watch them
Red-billed TropicbirdOP
Like just got to the url?
go
do i still access them through the bucket
no, you want to access these files though your cdn (cloudfront). You should've got a https://wdowkdok.cloudfront.net/ domain. Use this and add you filekey to it. For example https://wdowkdok.cloudfront.net/myfilekey.png
Red-billed TropicbirdOP
were do I see this in the dashboard?
is it my ditribution domain name?
if you enter your cloudfront dashboard, you should see your distributions here. You need the green thing
Red-billed TropicbirdOP
I get access denied
then you may misconfigured something
Red-billed TropicbirdOP
How do i configure it correctly because I correctly configured the bucket to allow me access
@Red-billed Tropicbird How do i configure it correctly because I correctly configured the bucket to allow me access
you can use cloudfront OAC for. Like that only the cloudfront distribution can get objects from your s3 and of course others as well, when they request though cloudfront. Take a look at this guide: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html
Red-billed TropicbirdOP
ok
Red-billed TropicbirdOP
I set everything up does it take some time to apply?
Becasue I have origin access set up and the cloudfront link is still access denied
@Red-billed Tropicbird I set everything up does it take some time to apply?
Yea, it takes some time. But not more than 1 hour (from experience)
Red-billed TropicbirdOP
ok