Uploading Images & Videos in React with the Cloudinary Upload Widget - Dev Hints

Sdílet
Vložit
  • čas přidán 17. 10. 2022
  • Set up easy image and video uploading for you or your visitors in a React app using the Cloudinary Upload Widget. Learn how to install and configure the upload widget including how to make the widget work with the intricacies of a React application.
    📝 Cloudinary Upload Widget
    cld.media/devhintsuploadwidge...
    💾 Using the Cloudinary Upload Widget with Upload Presets in React
    github.com/colbyfayock/cloudi...
    And if you're using a React framework like Next.js, here are some more examples:
    💾 Next.js Using the Cloudinary Upload Widget for Signed Uploads
    github.com/colbyfayock/cloudi...
    💾 Next.js Using the Cloudinary Upload Widget with Upload Presets
    github.com/colbyfayock/cloudi...
    Instructor: Colby Fayock ( @colbyfayock )
    --
    Cloudinary helps developers build performant experiences for the web with powerful optimization and transformation APIs.
    🚀 Get started with a free account!
    cld.media/devhintsuploadwidget
    #cloudinary #devhints #react #images #videos #webdevelopment
  • Věda a technologie

Komentáře • 34

  • @mindpower1332
    @mindpower1332 Před 17 dny +1

    amazing, i solve my 3 months pending error using this video

  • @biruktad3327
    @biruktad3327 Před měsícem

    Clear, concise and clean presentation. Thx.

    • @colbyfayock
      @colbyfayock Před měsícem

      no problem, glad you found it helpful!

  • @catreunion
    @catreunion Před rokem +1

    Thank you 🙏🏻

  • @Ddrcfszy
    @Ddrcfszy Před rokem

    Hey I took the example form github and it seems the in the first time I click upload widget it take few seconds till it’s open. Why?

    • @colbyfayock
      @colbyfayock Před rokem

      hey i had a similar question about this a few days ago. when you click the button it triggers createWidget which pulls in resources to initialize the widget UI (to avoid downloading those resources on page load). my solution is to use requestIdleCallback, where once the browser is idle, we can initialize that, which helps reduce that open experience
      if you try checking out the example it should be updated with that inside of the component. it wont let me post the link here unfortuantely, but same GitHub example

  • @eudeamonism
    @eudeamonism Před 10 měsíci

    How do you delete an image at client side? Is this a good practice? If not, what would be? Could you create a video showing this?

    • @colbyfayock
      @colbyfayock Před 10 měsíci

      when setting up your upload widget, you can use an upload preset that you configure to return a Delete Token, from there, you can see how you can delete it with the docs here: cloudinary.com/documentation/upload_images#deleting_client_side_uploaded_assets
      as far as good practice or not, it likely depends on the UX that you're creating around this feature, is the intent that users can delete their own images for instance? by providing that, are you opening yourself to lost data if they access that token? I would consider the use case first
      its a great idea for a video though, particularly the Delete Token, and we'll add it to the list!
      other options though worth mentioning are setting up an API endpoint and using the Node SDK or other serverside SDK in order to delete assets securely where you would have more control over who is able to hit that endpoint or not then trigger that from the UI when necessary

  • @jtaylor8606
    @jtaylor8606 Před rokem +1

    This is a good tutorial, but it needs removing and replacing with an up to date version: the menus have changes in cloudinary to find the settings and you now need to specify 'uploadPreset' rather than 'upload' in the widget component.

  • @fadlo1580
    @fadlo1580 Před 10 měsíci

    how to restrict upload to only authed users ? i need to use signed urls right ?

    • @colbyfayock
      @colbyfayock Před 10 měsíci

      yup! Signed Uploads are generally the best approach for handling restricting uploads. a good way to do this is by creating a serverless function that would include the code to sign the request. here's an example using Next.js...
      - Generate Signature Callback: github.com/colbyfayock/cloudinary-examples/blob/main/examples/nextjs-upload-widget-signed/components/UploadWidget/UploadWidget.js#L35
      - API Endpoint: github.com/colbyfayock/cloudinary-examples/blob/main/examples/nextjs-upload-widget-signed/pages/api/sign-cloudinary-params.js
      this can really be translated into anywhere you have the ability to surface server code that's callable from the client though
      from there, you'd likely also want to lock down the endpoint itself so that only authenticated users have the ability to call that endpoint, and that would depend on the authentication solution you're using, but it could be as minimal of a solution as checking for an active session at the beginning of the API handler and returning a 401 if they're not authenticated or authorized
      happy to help expand on this if needed!

  • @abiwendesen4747
    @abiwendesen4747 Před rokem +3

    how can i get the secure url of the uploaded content i want to send the secure url to my backend ?

    • @colbyfayock
      @colbyfayock Před rokem +4

      when initializing the upload widget, there's a callback function that you can use to capture different events, where you can see the resulting upload and use it as you'd like

    • @captaingaz8705
      @captaingaz8705 Před rokem

      @@colbyfayock can you be more specific please?

    • @colbyfayock
      @colbyfayock Před rokem +2

      @@captaingaz8705 hey, try checking out this example where i'm using the callback along with a prop to trigger functionaliy - inside the prop, I use the results to save the resource to state, which you could similarly do for a backend github.com/colbyfayock/cloudinary-examples/blob/main/examples/react-upload-widget-preset/src/components/UploadWidget/UploadWidget.js#L47

    • @oloja__
      @oloja__ Před rokem

      @@colbyfayock hey man. i saw the code but is there a way i can get the url immediately after i upload so i can send to the backend

    • @colbyfayock
      @colbyfayock Před rokem +1

      @@oloja__ in that linked example, the URL would be available at result.secure_url

  • @smartgowthamrazer
    @smartgowthamrazer Před rokem

    I Cannot resolve that props validation issue on UploadWidgets.js

    • @colbyfayock
      @colbyfayock Před rokem

      do you mean TypeScript? or what specifically are you referring to from a validation perspective?
      here are some types that might help: github.com/colbyfayock/next-cloudinary/blob/main/next-cloudinary/src/components/CldUploadWidget/CldUploadWidget.types.ts

  • @carlosgp4448
    @carlosgp4448 Před 9 měsíci

    Es posible hacerlo en angular ?

    • @colbyfayock
      @colbyfayock Před 4 měsíci

      si! github.com/cloudinary-community/cloudinary-examples/tree/main/examples/angular-upload-widget

  • @Sameer.Trivedi
    @Sameer.Trivedi Před rokem

    Please make a tutorial for signed uploads using React. The documentation is very hard to figure out.

  • @baqirhemani
    @baqirhemani Před 4 měsíci

    Hi cloudinary team, can we upload PDF Files in the system?

    • @colbyfayock
      @colbyfayock Před 4 měsíci

      yes! you can upload PDFs as long as you're not restricting them

    • @baqirhemani
      @baqirhemani Před 4 měsíci

      @@colbyfayock Can we get a tutorial on uploading multiple PDFs?

    • @colbyfayock
      @colbyfayock Před 4 měsíci

      @@baqirhemani i'll add it to my list!! in the meantime, using the upload widget, it should be similar to this video. alternatively, if you're working in a node environment, here's a tutorial for uploading multiple files czcams.com/video/_bTX2L0jPzA/video.html

  • @darshmostafa6138
    @darshmostafa6138 Před rokem

    but i can not upload a video

    • @colbyfayock
      @colbyfayock Před rokem

      what issue are you running into? you should be able to upload videos with this solution