Download a media file

I don’t see how to download a file stored in a media field. Don’t want to open it, just download whatever kind of file it is to the desktop or other location of the users choice.

I guess rightclicking the field will give you the options you’re looking for…

Or have a look at the file plugin…

Figured it out with a little help from a friend. Thought someone else might find this useful.

var mediafield = com_email_attach_blob; //name of media field
var fileName = plugins.file.showFileSaveDialog(); //let user choose destination and name

if (!mediafield)
{
var t = 1
}
else
{
var success = plugins.file.writeFile(fileName,mediafield);
if (!success) plugins.dialogs.showWarningDialog(‘Warning’, ‘Could not write file’, ‘OK’);
}