Simple Image Upload

System Information
  • Strapi Version: 3.6.8
  • Operating System: macOS 11.6
  • Database: sqlite
  • Node Version: 16.13.0
  • Yarn Version: 1.22.11

Hi! I am trying to import data from a WordPress site to Strapi. I am able to import all the data and link all the relations nicely but have been having a really hard time getting the images to import.

When looping through the posts to import I need to download an image from an external URL and associate it with the post being imported.

I’ve really tried/googled everything I could think of. I feel like I’m missing something simple and keep getting lost in a sea of out-dated documentation.

I’m using axios just because that is what I started with. Open to using anything that works. I’m really surprised uploading images like this has been so hard to figure out. Any help or point in the right direction is very appreciated.

Here is a hard-coded example of what I am trying which is not working:

const img = await axios.get('', {
	responseType: 'blob',

const formData = new FormData()
formData.append('files', img)
formData.append('ref', 'shows')    // collection name
formData.append('refId', '1721')   // post ID
formData.append('field', 'photos') // field name

res = await'http://localhost:1337/upload', {
	data: formData,
	headers: {"Content-Type": "multipart/form-data"}

Output from trying the above code:

Using the same data via Postman seems to work fine. The image uploads and get associated with the correct post. So I think it must be something with the way I am sending the request.