Skip to main content
Participant
May 3, 2019
Question

Panel doesn't open a download file dialog

  • May 3, 2019
  • 1 reply
  • 973 views

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

// define a route to download a file

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?

This topic has been closed for replies.

1 reply

Bruce Bullis
Community Manager
Community Manager
May 7, 2019

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.

Jarda Bereza
Inspiring
May 7, 2019

That should be part of Node.js

Bruce Bullis
Community Manager
Community Manager
May 7, 2019

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.