How I Upload Images to CloudFlare R2 in Next.js Server Components (Presigned PUT)

  Рет қаралды 6,689

TomDoesTech

TomDoesTech

Күн бұрын

Пікірлер: 29
@MadTofan
@MadTofan 2 ай бұрын
This video is a life saver. Been stuck for a really long time with this, but after solving the issue, I noticed some of my uploads had failed due to CORS issue. turns out it was because my key in command had a space (I was relying on the file name to define the object key). I ended up generating a uuid for the object key instead.
@coolvibes-nj2cc
@coolvibes-nj2cc Ай бұрын
I am also stuck bro. do you mind sharing your code here?
@MadTofan
@MadTofan Ай бұрын
@ i just followed the code in the video here. Except for the file key, I used uuid to always have a new unique one
@Next-Js
@Next-Js Ай бұрын
Thank you, your content helps me a lot, keep it up, cloudflare is great for me!
@abhishekbarkade5955
@abhishekbarkade5955 5 ай бұрын
Love you man! I was facing issue to connect with client from my node app for an whole day, found solution to my issue in few minutes only. Thank you so much 🙇‍♂
@ckhicks
@ckhicks 5 ай бұрын
Thanks mate, this was helpful!
@V0LAT1LE_
@V0LAT1LE_ 7 ай бұрын
Tom: There won't be many tutorials on this channel anymore Also Tom a few days later: Makes Tutorial*
@TomDoesTech
@TomDoesTech 7 ай бұрын
This isn't really a tutorial. This is the kind of video I'll be making in the future
@V0LAT1LE_
@V0LAT1LE_ 7 ай бұрын
@@TomDoesTech thats great man 😃
@Kevinisyoung
@Kevinisyoung 2 ай бұрын
Thank you very much for making this video
@andreik917
@andreik917 4 ай бұрын
Could you share repo with the example ?
@naylord5
@naylord5 7 ай бұрын
Thank you Tom for this useful video! 🔥🔥 Could you please consider extending this with a multi file upload with individual progress? It would be a game changer for me.
@TheAliAhad
@TheAliAhad 7 ай бұрын
Thanks, It would be great to make a tutorial about D1 also.
@eip408
@eip408 5 ай бұрын
awesome tuts, thanks Tom 🙌! just got into some issues although I can successfully store the image into my bucket, but I cannot get the src itself and keep getting that xml error response edit: fixed the issue, just need to do the GetObjectCommand to retrieve the images after putting it to the bucket
@TomDoesTech
@TomDoesTech 5 ай бұрын
@@eip408 you can either make the bucket reads public, or do the signed get request
@eip408
@eip408 5 ай бұрын
​@@TomDoesTech ohh I see, thanks Tom and appreciate for the quick response
@Its-InderjeetSinghGill
@Its-InderjeetSinghGill 6 ай бұрын
Hey, really liked this video. I have one question, What if we need to upload multiple files do we need to create multiple signed urls for that?
@TomDoesTech
@TomDoesTech 6 ай бұрын
Yeah, I think you have to make multiple URLs. I haven't done it to be honest so I'm not sure
@eddyhernandez2475
@eddyhernandez2475 7 ай бұрын
3600 seconds is an hour haha 12:57
@TomDoesTech
@TomDoesTech 7 ай бұрын
I was thinking it was ms
@regilearn2138
@regilearn2138 7 ай бұрын
How to upload files to the aws s3 bucket using lambda functions
@PsychoDude
@PsychoDude 4 ай бұрын
in express
@Tboy_ty
@Tboy_ty 7 ай бұрын
Your font is small...kindly try to enlarge next time...thank you for all you do.
@reqtified
@reqtified 4 ай бұрын
Sadly, I just get CORS issues doing this, even with a custom domain.
@TomDoesTech
@TomDoesTech 4 ай бұрын
@@reqtified you're either using the wrong creds or haven't setup the cors policy. I did show what to do if you get that in the video
@reqtified
@reqtified 4 ай бұрын
@@TomDoesTech totally me, sorry. It ended up having a ';' on the bucket name at the end!! Been debugging for days and only have just found it!! urgh, one of those ones XD
@PremJethwa-qj2mp
@PremJethwa-qj2mp 7 ай бұрын
Hi Tom Thanks for such a helpfull video, I'm Facing one issue while accessing the image in FrontEnd using the Token (ReadOnly access) Here is how I'm call export const fetchMedia = async (url) => { const token = "myToken"; // Replace with your actual access token try { const response = await axios.get(url, { method: "GET", headers: { Authorization: `Bearer ${token}`, }, }); if (!response.ok) { console.error( `Failed to fetch media: ${response.status} ${response.statusText}` ); console.error("Response details:", await response.text()); throw new Error(`Failed to fetch media: ${response.statusText}`); } const blob = await response.blob(); const mediaUrl = URL.createObjectURL(blob); return mediaUrl; } catch (error) { console.error("Error fetching media:", error); return null; } };
@TomDoesTech
@TomDoesTech 7 ай бұрын
Why do you need to fetch the image on the frontend? I don't understand
Don't Make These Next.js Mistakes
13:01
Dave Gray
Рет қаралды 24 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
How I Build REST APIs that Scale
1:06:56
TomDoesTech
Рет қаралды 7 М.
How I Would Build a Software System for Scale
15:54
TomDoesTech
Рет қаралды 6 М.
How I Built a Marketplace with Stripe Connect
13:21
TomDoesTech
Рет қаралды 8 М.