Hello all. I have written a bit of code that performs the following steps:
-
A lightbox is presented to the user with some data and a download button. When a user clicks on one of the download buttons, a backend call is made which does:
-
Generate some bibliographic text
-
Save it as a .txt file to the Media Manager (I would save it as an extension like .ris or .bib, but those MIME types are not allowed)
-
Return the result of calling mediaManager.getDownloadUrl
The problem here is that the result of mediaManager.getDownloadUrl is returning filename.txt
instead of filename.bib
. Here is a small sample of code to demonstrate what I’m talking about.
export async function DownloadCitation(citation, fileName, downloadFileName) {
let b = Buffer.from(citation);
let uploadResult = await mediaManager.upload("/citations", b, fileName, {
"mediaOptions": {
"mimeType": "text/plain",
"mediaType": "document"
}
});
let downloadURL = await mediaManager.getDownloadUrl(uploadResult.fileUrl, null, downloadFileName, null);
return downloadURL
}
The documentation (getDownloadUrl - Velo API Reference - Wix.com) implies that the third argument will allow me to specify the actual downloaded file’s name. However, that does not seem to work.
Any thoughts?