An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
April 13, 2022 10:59 am GMT
Original Link: https://dev.to/dingzhanjun/how-to-place-a-file-generated-from-strapi-backend-js-code-444k
How to place a file generated from strapi backend js code
const mime = require('mime-types'); //used to detect file's mime type
${rootDir}/public/uploads/${fileName}`
const fs = require('fs');
const rootDir = process.cwd();
const fileName = 'test.csv';
const filePath =
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,
},
});`
https://forum.strapi.io/t/strapi-upload-plugin-how-to-place-a-file-generated-from-strapi-backend-js-code/3323
Original Link: https://dev.to/dingzhanjun/how-to-place-a-file-generated-from-strapi-backend-js-code-444k
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To