Uploading Images & Videos in Next.js with Cloudinary - Dev Hints

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 25. 12. 2023
  • Set up easy image and video uploading for you or your visitors in a Next.js app using the Cloudinary Upload Widget.
    Learn how to setup and configure the CldUploadWidget component including adding the ability to sign uploads for secure uploads to your Cloudinary account.
    📝 Next Cloudinary CldUploadWidget Docs
    next.cloudinary.dev/cldupload...
    Instructor: Richard Bray (@RichardBray)
    --
    Cloudinary helps developers build performant experiences for the web with powerful optimization and transformation APIs.
    🚀 Get started with a free account!
    cld.media/nextclduploadwidget
    #cloudinary #devhints #nextjs #uploadvideo #uploading #fileupload #webdevelopment
  • Věda a technologie

Komentáƙe • 19

  • @user-dz3ub5pb6v
    @user-dz3ub5pb6v Pƙed 6 měsĂ­ci +1

    index.mjs:1 Missing dependency: Signed Upload requires an API key
    that is what I have in the browser's devtools console when just after refreshing the page... I have created the same api route, and it even generates a signature as I see in the server console but when I am trying signed preset it says "uploading 0 assets" and doesn't end uploading at all, as in the unsigned preset case where even if something goes wrong with the preset name, it is trying at least to load that image and once it is 'uploaded' it just says something like: "there is no such preset". I tried all the same code as in the video and it works well with unsigned preset, but with the signed one, it requires an API key, and I can't find a good resource where I will see where to pass that API key. I have tried to pass it in the as a parameter, but it doesn't distinguish it, and nothing except for chatgpt says that it can be used that way. There is no source which will have the good description of how to do signed preset uploads with CldUploadWidget

    • @raj-dr2iy
      @raj-dr2iy Pƙed 5 měsĂ­ci +2

      In order to sign the requests, you need to use Cloudinary API Key and Secret, so set additional environment variables:
      NEXT_PUBLIC_CLOUDINARY_API_KEY=""
      CLOUDINARY_API_SECRET=""

    • @colbyfayock
      @colbyfayock Pƙed 4 měsĂ­ci

      @@raj-dr2iy is there anywhere i can add something to make this more clear?

    • @raj-dr2iy
      @raj-dr2iy Pƙed 4 měsĂ­ci

      Sure! Firstly, ensure to set up a .env file with all the credentials in the project's root directory.@@colbyfayock

    • @maneshwar3468
      @maneshwar3468 Pƙed 2 měsĂ­ci

      @@raj-dr2iy Thanks for sharing.

    • @maneshwar3468
      @maneshwar3468 Pƙed 2 měsĂ­ci

      @@colbyfayock Yes, include about the environment settings in the video.

  • @arditqerimi745
    @arditqerimi745 Pƙed 24 dny +1

    I placed all secret variables in .env, also in server action I am able to console all of them, but again it says API Key undefined

    • @colbyfayock
      @colbyfayock Pƙed dnem

      do they match the following names?
      NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=""
      NEXT_PUBLIC_CLOUDINARY_API_KEY=""
      CLOUDINARY_API_SECRET=""
      API key needs to be public specifically

  • @lev1ato
    @lev1ato Pƙed 4 měsĂ­ci +1

    I am not able to build production nextjs app with:
    import { v2 as cloudinary } from 'next-cloudinary';
    it says:
    Module not found: Can't resolve 'http'
    and so on for all the modules
    Please help me

    • @lev1ato
      @lev1ato Pƙed 4 měsĂ­ci

      export const runtime = 'edge';
      Breaks it, but it is needed for deploying to production.... Please help me figure it out.

    • @colbyfayock
      @colbyfayock Pƙed 4 měsĂ­ci +1

      @@lev1atohey unfortunately the Node SDK isn't supported on Edge runtime :( you would either need to use the standard runtime for the endpoints that use the Node SDK or manually write the code to hit the REST API and sign the requests. i have an example of how i've done that before here: github.com/colbyfayock/tweezer/blob/main/src/pages/api/upload.js

    • @mantasbeniusis9777
      @mantasbeniusis9777 Pƙed 4 měsĂ­ci

      You should import it from a different package. Note that it is from 'cloudinary' and not 'next-cloudinary'

    • @lev1ato
      @lev1ato Pƙed 4 měsĂ­ci

      @@mantasbeniusis9777 yeah I made a typo above, but the example Colby gave me actually helped me solve it. I just had to make couple of changes to make it work with the Next.js App router.

  • @eunarussia8833
    @eunarussia8833 Pƙed 3 měsĂ­ci

    I'd like to know how do I upload multiple images with cloudinary (using Next.js)

    • @colbyfayock
      @colbyfayock Pƙed 2 měsĂ­ci

      if you're uploading in a node environment, here's a video that can help: czcams.com/video/_bTX2L0jPzA/video.html
      otherwise, let me know how you're uploading and i can give some advice

  • @_bestbeast
    @_bestbeast Pƙed 6 měsĂ­ci

    I am facing problems that I am not able to click any link aur button of upload widget

    • @colbyfayock
      @colbyfayock Pƙed 6 měsĂ­ci

      are you using CldUploadWidget? try checking out this example that shows how to set up a button, including adding the onClick handler to open the widget: github.com/cloudinary-community/cloudinary-examples/blob/main/examples/nextjs-clduploadwidget/pages/index.js#L44

  • @keyzhao1775
    @keyzhao1775 Pƙed 8 dny

    only cover image not cover uploading video as title

    • @colbyfayock
      @colbyfayock Pƙed dnem

      hey you're right in that the video doesnt specifically upload a video file but the same exact process works just the same for videos (or any other files) unless you limit it specifically to images, so it "just works"