Hi everyone,
I’m trying to add img by ur using the upload services, I saw something like this :
const mime = require('mime-types'); //used to detect file's mime type
const fs = require('fs');
const rootDir = process.cwd();
const fileName = 'test.csv';
const filePath = `${rootDir}/public/uploads/${fileName}`
const stats = fs.statSync(filePath);
//uploading it directly to upload services.
await strapi.plugins.upload.services.upload.upload({
data:{}, //mandatory declare the data(can be empty), otherwise it will give you an undefined error.
files: {
path: filePath,
name: fileName,
type: mime.lookup(filePath), // mime type of the file
size: stats.size,
},
});
Nevertheless, I try to replace the filepath by my img url, but I have an error :
"errors": [
{
"id": "Upload.status.empty",
"message": "Files are empty"
}
]
How can I upload my image using his url ?
thanks