Copy link to clipboard
Copied
In my panel I download a file via a nodeJS URL. When I test this page via my browser, it visits the URL, downloads the file to the server, and then opens a filedialog window to ask you to place it.
script.js
// TODO: DOWNLOADING TEST //
////////////////////////
let btnDownload = document.getElementById("btnDownload");
btnDownload.addEventListener('click', function () {
window.location.href = 'http://localhost:3000/downloadmedia?productionid='+productionId+'&mediaid='+mediaId;
}
The nodeJS server code
app.get('/downloadmedia/', async (request, response) => {
//Setup API client & connection
//...
// Downloading file to server via API
//...
console.log("Downloading file to __dirname + /temp/: " + __dirname + "/temp/");
await mediaObject.download(__dirname + '/temp/');//Download file and place in temp folder
let file = mediaObject.structuredDescription.fileName; //mediaobject filename
console.log("Downloaded : " + mediaObject.structuredDescription.fileName);
let fileLocation = __dirname + "\\temp\\" + file; //Complete path
console.log("FileLocation = " + fileLocation);
//Send the download response, and browser asks user for location
response.download(fileLocation);
});
HOWEVER, when I click the same button but in the panel in Premiere Pro, the logs state that it still downloads the file correctly, but doesn't open a filedialog to ask the user for a location to place it to. How can I solve this?
Copy link to clipboard
Copied
Sorry, potentially ignorant question: Where does the value for _dirname come from? It seems like that isn't getting set correctly, in the panel case.
Copy link to clipboard
Copied
That should be part of Node.js
Copy link to clipboard
Copied
But you'll need to modify it anyway, because (in the example above) it's downloading into the extension's own directory. That'll work okay for an unsigned panel while debugging, but modifying the contents of an extension's directory will invalidate its signature, and make it no longer load.