Files are uploaded but they are not created in relation with the components defined in the collection-type. Is there any possible solutions to embed the files data to the fields?

System Information
  • Strapi Version: 4.2.0
  • Operating System: Windows
  • Database: Postgresql
  • Node Version: 16.15.1
  • NPM Version: 8.3.1

I try to customize the post request with the create function in the controller. I was able to upload the files and write the data to the database. But, what I am not able to achieve is that the uploaded files are not embedded in the fields which are in the components. Let me show my code below,

Request made in postman,

 async create(ctx) {
      if ("multipart")) {
        const { data } = ctx.request.body;
        const { files } = ctx.request;
        const parsedData = JSON.parse(data);


        const entity = await strapi
            data: {
              kyc: {
                business_license: "this is business license",
            files: {
              owner_photo: files["owner_photo"],

The uploaded files are successfully created in the media library. I want to embed the files data to the fields inside the kyc components. Please kindly advise me how to overcome this problem.

After thorough reading other post having the similar issues, I have found out the proper way to upload the files and update the database.
Follow the sequence…
First upload the image then get the id
Update the data with the image id

It will work perfectly.

1 Like