Copy link to clipboard
Copied
Is it possible to create a jsx script to download a file?
In ExtendScript you can use Kris Coppieters's
In UXP you can use one of the standard modules.
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.
Copy link to clipboard
Copied
In ExtendScript you can use Kris Coppieters's
In UXP you can use one of the standard modules.
Copy link to clipboard
Copied
In addition to Peter's excellent suggestions, you can also write a curl string command and execute it via VB or AS depending on OS.
Copy link to clipboard
Copied
Another option for windows is Autohotkey script
One line code.
Example:
UrlDownloadToFile, http://someorg.org/archive.zip, C:\SomeOrg's Archive.zip
Copy link to clipboard
Copied
Another option could be to create an invisible CEP extension and then send CSXS event from jsx to js for downloading the file.
-Manan
Copy link to clipboard
Copied
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();
}
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more