I’m building a React Next.js gui on top of the Strapi CMS.
I have a requirement to upload an image (jpg/png/etc) to Strapi from a URL in my Next.js app.
I can find plenty of documentation regarding how to upload an image using a file picker and then doing say setImage(e.target.files[0]) to select the image, but that doesn’t work when loading from a URL.
Do i need to read in the file from the URL and convert to a blob first?
Here’s the standard code which uploads an image to Strapi and connects it to an event (as in a ‘real world’ event). This works fine with a file picker, but not from a URL:
This is interesting, I haven’t tried it yet, but I think it will be cool to have that as a feature in the app that I am currently building. Here is something I found when researching, maybe it can help.
I think this can help with the first part of getting the image from url
I am putting all of this here, so I can use this as notes too.
But going to try to create react component that gets image from url, shows preview, and allows you to uploaded to strapi.
I think this is a cool idea.
If you get it working ( before me ) in NextJS let us know how you did.
I started to work on this basic implementation, it is not done, yet. But you can mess around with it to see if you can take it the rest of the way.