Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function canWrite(path, callback) {
- fs.access(path, fs.W_OK, function (err) {
- callback(null, !err);
- });
- }
- function downloadFile(url, target, target_name) {
- canWrite(target, function (err, isWritable) {
- if (isWritable){
- electronDl.download(
- BrowserWindow.getFocusedWindow(),
- url,
- {
- directory: target,
- filename: target_name
- }
- )
- console.log("Downloaded from: " + url + " to: " + target);
- return true;
- } else {
- console.log("No permission to write to target");
- return false;
- }
- });
- }
- downloadFile(REMOTEURL, app.getPath('userData'), 'sessionfile.json');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement