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

Поділитися
Вставка
  • Опубліковано 1 жов 2024
  • repoz.io: www.repoz.io
    🌎 Follow me here:
    Discord: / discord
    Twitter: / tomdoes_tech
    Facebook: / tomdoestech​
    Instagram: / tomdoestech​
    TikTok: / tomdoes_tech
    ☕ Buy me a coffee: www.buymeacoff...

КОМЕНТАРІ • 24

  • @eddyhernandez2475
    @eddyhernandez2475 3 місяці тому +3

    3600 seconds is an hour haha 12:57

    • @TomDoesTech
      @TomDoesTech  3 місяці тому +1

      I was thinking it was ms

  • @osanyinbiyusuf7308
    @osanyinbiyusuf7308 4 місяці тому +1

    Your font is small...kindly try to enlarge next time...thank you for all you do.

  • @ckhicks
    @ckhicks 2 місяці тому +2

    Thanks mate, this was helpful!

  • @andreik917
    @andreik917 Місяць тому +1

    Could you share repo with the example ?

  • @reqtified
    @reqtified Місяць тому

    Sadly, I just get CORS issues doing this, even with a custom domain.

    • @TomDoesTech
      @TomDoesTech  Місяць тому

      @@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 Місяць тому

      @@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

  • @eip408
    @eip408 2 місяці тому +1

    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  2 місяці тому +1

      @@eip408 you can either make the bucket reads public, or do the signed get request

    • @eip408
      @eip408 2 місяці тому

      ​@@TomDoesTech ohh I see, thanks Tom and appreciate for the quick response

  • @naylord5
    @naylord5 4 місяці тому

    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.

  • @abhishekbarkade5955
    @abhishekbarkade5955 2 місяці тому

    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 🙇‍♂

  • @TheAliAhad
    @TheAliAhad 4 місяці тому

    Thanks, It would be great to make a tutorial about D1 also.

  • @Its-InderjeetSinghGill
    @Its-InderjeetSinghGill 2 місяці тому

    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  2 місяці тому

      Yeah, I think you have to make multiple URLs. I haven't done it to be honest so I'm not sure

  • @regilearn2138
    @regilearn2138 4 місяці тому

    How to upload files to the aws s3 bucket using lambda functions

  • @V0LAT1LE_
    @V0LAT1LE_ 4 місяці тому

    Tom: There won't be many tutorials on this channel anymore
    Also Tom a few days later: Makes Tutorial*

    • @TomDoesTech
      @TomDoesTech  4 місяці тому +2

      This isn't really a tutorial. This is the kind of video I'll be making in the future

    • @V0LAT1LE_
      @V0LAT1LE_ 4 місяці тому

      @@TomDoesTech thats great man 😃

  • @PremJethwa-qj2mp
    @PremJethwa-qj2mp 3 місяці тому

    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  3 місяці тому

      Why do you need to fetch the image on the frontend? I don't understand