Is it possible to download a file with dialogue?

63 views
Skip to first unread message

Toto

unread,
Nov 21, 2013, 2:01:33 AM11/21/13
to appj...@googlegroups.com
Good morning to all,

I'm trying to download a file from my server to the user's computer. And you may specify where it should be downloaded.

Is there any way to do this?

I'm with:
 
window.frame.openDialog({
    type
: 'save',
    title
: 'Save...',
    multiSelect
: false,
    dirSelect
:true,
    initialValue
:'c:\\Program Files'
}, function( err , files ) {
 
   
var http = require('http');
var fs = require('fs');


var file = fs.createWriteStream("image.png");
var request = http.get("http://miserver.com/image.jpg", function(response) {
  response
.pipe(file);
});
});


That code I save the file, but not where the user has indicated. Also, I can not know how much has downloaded ... Is it possible?

Hehe .... thanks for reading 

sihorton

unread,
Nov 21, 2013, 4:14:09 AM11/21/13
to appj...@googlegroups.com
Hi Toto,

I found the following on stack overflow: http://stackoverflow.com/questions/4771614/download-large-file-with-node-js-avoiding-high-memory-consumption. You can also see the following answer to get the total number of bytes you need to download: http://stackoverflow.com/questions/18323152/get-download-progress-in-node-js-with-chunks.

So while you are downloading you can count the number of bytes you have gotten with data.length and update a variable. Then in appjs you can update a particular div or span with that number, in deskshell you would send a message over the socket to the browser and it could then update the gui.

/Simon

Toto

unread,
Nov 21, 2013, 7:49:33 AM11/21/13
to appj...@googlegroups.com
Thanks!! Simon!
Reply all
Reply to author
Forward
0 new messages