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 (ctx.is("multipart")) {
console.log("multipart/form-data");
const { data } = ctx.request.body;
const { files } = ctx.request;
const parsedData = JSON.parse(data);
console.log(files["owner_photo"]);
const entity = await strapi
.service("api::agent-modification.agent-modification")
.create({
data: {
...parsedData,
kyc: {
business_license: "this is business license",
},
},
files: {
owner_photo: files["owner_photo"],
},
});
console.log(entity);
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.