How to upload file to relation in Strapi V4

System Information
  • Strapi Version: 4.0.0
  • Operating System: Windows 10
  • Database: PostgreSQL
  • Node Version: 14.0.0
  • NPM Version: 6

So I have Users (from users-permissions) & I added a avatar to the content type. For my front-end I’m using Next.js how can I upload the photo to the avatar field via API???

This answer is relevant to API calls using REST with Strapi V4.

Unlike other collections, users-permissions does not allow you to upload files during creation (like in the register call). To get this to work, you can wait until the register POST call returns, then make a second call using upload with the instructions found here: upload files related to an entry

Another way (ugly) would be to override the register call for the users-permissions plugin and do the upload in code yourself.

1 Like