1

if (exportdata != null) {
  var blob = new Blob([s2ab(exportdata.filedata)], {
    type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  });
  //saveAs provided by FileSaver.js
  saveAs(blob, exportdata.filename);
  framework.displayAlert('ERRORS.SUCCESS', 'Data downloaded successfully');
} else {
  framework.displayAlert('ERRORS.ERROR', data.error);
}


function s2ab(s) {
  var buf = new ArrayBuffer(s.length);
  var view = new Uint8Array(buf);
  for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
  return buf;
}

In saveAs() I have given the file type and filename. It will save with the given file name in the downloads folder. But I want to save it in D://Reports/sample/ this path. Is there any options to achieve this?

1
  • I also want to send that file to ftp server location Commented Aug 1, 2018 at 9:50

1 Answer 1

3

This cannot be done. The browsers for obvious security reasons doesn't allow files to be saved to specific locations only by the user (by right click -> save as) it won't allow you to set the destination folder.

Otherwise imagine that any site would be able to save files where ever it wants on your computer.

If you need to save Blobs to specific locations you will have to do it on the server side. Upload the Blob to your server and then you'll be able to save it where ever you want to.

Sign up to request clarification or add additional context in comments.

6 Comments

I accept this. Once I export file, for eg, it will save in downloads folder. Is this possible to move that file to another path
Not through the browser. You will either have to run a filesystem watcher on the downloads directory or do as I suggested and just upload it to your server and the save it where you like
How do I upload blob to my server?
@Raghul it depends on which type of serverside you use. Just notice that you'll be able to save it on the server / ftp or anywhere else but not in the end users computer. Anyway I recommend for you to look for how to upload files/blobs on google. There are tons of examples
I want to move that file to ftp location path
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.