-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Description
Bug report
Hello, I am very new in strapi and I don't know, how strapi works internally in backend but I have one hosted strapi given by the client and I am working on it.
I have problem to upload image into components component
like
I have one collection called order, on that I have one component called opc and on that I have one component called director and on that I have one field called 'image', I want to upload my image on that and also want to link that.
order > opc > director ( want to upload here in image field )
Code
const fileData = new FormData();
fileData.append(
`files`,
value,
`${new Date().getTime()}_${key}_${type[1]}`
);
// fileData.append("ref", "order");
fileData.append("ref", "order.opc.director");
// fileData.append(`refId`, order);
fileData.append(`refId`, order.opc.director.id);
fileData.append(`field`, 'image');
fileData.append(
"fileInfo",
JSON.stringify({ alternativeText: value.name })
);
const res = await axios({
method: "POST",
url: "https://api.example.com/upload",
headers: {
Authorization: `Bearer ${token}`,
"Content-type": "multipart/form-data",
},
data: fileData,
});is it right code? or I am doing something wrong here?
System
- Node.js version: 14.17.0
- NPM version: 7.11.2
- Operating system: Ubuntu 20.04
can someone please help me to add image on that component?
Metadata
Metadata
Assignees
Labels
No labels
