Posting an image using a URL from an API call

Hi I wanted to ask if it is possible to ‘POST’ or upload an image from a URL.

I have and API from rapid API and I want to save the data to Strapi. The data includes images which are in the form of a URL. So I would like to be able to call the API from rapid API and then take the response data and save it to a new custom content that I have created. The image will be uploaded to Strapi and will no longer rely on the API so in the future all the images and data will be saved on my server/database.

Im still learning at the moment and hope the above makes sense.

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

Hi

Yes, you have an option to do this

const image = await axios.post(`${strapi_URL}/upload`, <image>, {
        headers: {
          Authorization: `Bearer ${user.jwt}`,
        },
      })

      const imageId = image.data[0].id

By using this code you can store your image in upload entity, it will give you image object.
Then you will be able to set imageId to your API

1 Like

Thank you for the response and sorry I never seen it sooner. Im guessing that in this would be the URL of the image I would like to upload ?