According to https://www.wix.com/velo/reference/wix-media-backend/mediamanager-obj/upload, this should upload a csv file to the media manager.
When the function completes, the folders are created but the file is not. The returned file info object contains a url, but navigating to it with wixLocation.to(..)
just shows the word “Forbidden”.
import { mediaManager } from 'wix-media-backend';
...
const now = new Date();
const fileInfo = await mediaManager.upload(
`/reports/orders/${now.getFullYear()}`,
Buffer.from(myCsvString),
'report.csv',
{
"mediaOptions": {
"mimeType": "text/csv",
"mediaType": "document"
},
"metadataOptions": {
"isPrivate": true, // true or false makes no difference
"isVisitorUpload": false,
"context": {
"generatedAt": now.toUTCString()
}
}
}
);
console.log(fileInfo);
It doesn’t seem to matter what the file content is or what the metadata options are.