Hi, I'm trying to implement the example of downloading files from a server using PhonegapFiledownload, and first parameter can be an array of file names.
Basically, the instructions say: Specify the name of a Javascript function to call. this function must return an array containing the names of files that you want to download. You can specify fully qualified files or relative files (paraphrasing the last sentence).
The steps are:
1. Do ajax callback to get a list of urls and put them into {dialog.object}._urlToFetch. Here is the relevant parts to the callback:
I am stuck on how to make url an array instead of a single variable, and pass that along to fetchfile2, and have fetchfile2 parse it. Here is fetchfile2 code:
Now, I'm guessing the fetchfile2 is already setup to handle an array, but I can't say for sure because I am not understanding all of it.
Anyway, How do I make url above an array and pass multiple urls and is fetchfile2 already setup to handle that array?
THANK YOU!!
Basically, the instructions say: Specify the name of a Javascript function to call. this function must return an array containing the names of files that you want to download. You can specify fully qualified files or relative files (paraphrasing the last sentence).
The steps are:
1. Do ajax callback to get a list of urls and put them into {dialog.object}._urlToFetch. Here is the relevant parts to the callback:
Code:
'get the URL for this session file dim url as c url = Session.FormatFileDataURL(clientSideFileName) 'construct the Javascript response that will be sent to the client 'note that we specify that a function called 'fetchFile()' should be called 'on the client-side with the name of the URL that points to the temporary 'file in session storage. This 'fetchFile()' function is a user-defined 'Javascript function that you will need to add to your UX component dim js as c js = "" js = js + "{dialog.object}._urlToFetch = '" + url + "';" + crlf() js = js + "fetchFile2('" + js_escape(url) + "');" // <-- I changed to fetchfile2 to trigger automatic download 'note: if you want to automatically trigger the file download after the ajax callback has completed 'change the call to fetchFile2(). xb_getData = js
Code:
function fetchFile2(url) { var arr = []; arr.push( {filename: url} ); var options = { targetFolder: '__myAlphaFiles', showProgress: true, forceDownloadIfFileExists: true, onComplete: function(array) { //alert('file was downloaded'); readFiles(); }, onError: function(array,arrayIndex) { alert('error'); }, progress: { color: '#9fa1e8', width: '300px', allowCancel: false, progressElement: '{dialog.componentname}.V.R1.PLACEHOLDER_1' } } {dialog.object}.phoneGapFileDownload(arr,options); }
Anyway, How do I make url above an array and pass multiple urls and is fetchfile2 already setup to handle that array?
THANK YOU!!
Comment