Script for downloading a file
Is it possible to create a jsx script to download a file?
Is it possible to create a jsx script to download a file?
I ended upp using this approach. My plugin is writte in angular.js.
I use this .js code to download the file:
fac.downloadFile = function (url) {
var deferred = $q.defer();
return $http({
method: 'GET',
url: url,
responseType:'arraybuffer',
headers: {
'Content-Type': undefined
},
transformResponse: function (data) {
return data;
}
});
}
The I use the following code in jsx to save the file to disk:
function cargo_WriteFileToDisc(object) {
var string = unescape(object);
var errorString = "";
var docObject = JSON.parse(string);
var doc = app.activeDocument;
var imagePath = File(doc.filePath + "/" + docObject.filename);
if (docObject.imageData != null)
{
imagePath.open("w");
imagePath.encoding = "BINARY";
imagePath.write(docObject.imageData);
imagePath.close();
}
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.