{
0|strapi | error: { message: ‘Request Timeout’, http_code: 499, name: ‘TimeoutError’ }
0|strapi | }
But it works in admin panel succesfully
Can anyone please
If you are not calling /upload directly and are uploading an image as part of the content update then you need to follow the pattern described in Upload | Strapi Documentation
I have a similar case (see image)
It is not working unfortunately i get server error for no reason
Its cloudinary timeout but in admin panel it works
Hello anyone please help
Can you post JavaScript code you are using for upload
you need to use FormData and:
formData.append('files.thumb', file)
Or files.thumb[0]
If thumb is inside component you need to use:
files.nameOfComponent.thumb
import axios from "axios";
var fs = require('fs');
let headersList = {
"Accept": "*/*",
"User-Agent": "Thunder Client (https://www.thunderclient.com)",
"Authorization": "Bearer cc36581924960f53ad90a68ec41f21b5dbed6a8ea66c94bd96c0531a7cc0eaa34ef3813f98fdde877a25c3f0321b32212b29fd9d193578efb354a55f759140484e1be36a92ba0caade096b51c3cc4c34e6ee90f89b3524ab42070893967dd79b99781d73d4e7955569b87164b801a291f52ed92ee86818b6efcf3c7d9ae618fb"
}
let formdata = new FormData();
formdata.append("thumb.media", fs.createReadStream("/Users/vaarunsinha/Desktop/Cloudinary/10R 280W.jpg"));
let bodyContent = formdata;
let reqOptions = {
url: "https://backend.anoralux.com/api/products/535/",
method: "PUT",
headers: headersList,
data: bodyContent,
}
let response = await axios.request(reqOptions);
console.log(response.data);
This is how a product looks when I get all the fields
{
"kind": "collectionType",
"collectionName": "products",
"info": {
"singularName": "product",
"pluralName": "products",
"displayName": "product",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
},
"slug": {
"type": "uid",
"targetField": "name"
},
"thumb": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files",
"videos",
"audios"
]
},
"images": {
"type": "media",
"multiple": true,
"required": false,
"allowedTypes": [
"images"
]
},
"category": {
"type": "enumeration",
"enum": [
"Event & Stage Lights",
"Digital Display",
"Architectural Lights",
"Auditorium Lights",
"Industrial Lights"
]
},
"subcategory": {
"type": "relation",
"relation": "manyToOne",
"target": "api::subcategory.subcategory",
"inversedBy": "products"
},
"description": {
"type": "richtext"
}
}
}
I have tried files.attributes.thumb as well
TypeError: Cannot read properties of undefined (reading 'data')
I have this in my console
Uploading images is working in the admin panel
Please help
Please help
I am able to upload many files using the below approach
const formData = new FormData();
inputs.files.forEach(({ file }) => {
formData.append(`files`, file, file.name);
});
const data = {
...someData
};
formData.append("data", JSON.stringify(data));
Looking at your request it is difficult for me to say but have you tried something like:
formData.append('files', fileStream, 'myfile.jpg');