Can I automatically open a file once it finishes to download??

39 views
Skip to first unread message

Juri Strumpflohner

unread,
Mar 31, 2014, 5:38:40 AM3/31/14
to node-...@googlegroups.com
Hi,

I currently use node-webkit to load our **remote web application**. That is, at startup I have something like

...
window.location.href = appConfig.productionUrl;
...

Why node-webkit then? Well because my webapp needs to integrate with some more advanced workstation functionality which is where node.js and hence node-webkit comes in handy.
There is a "problem" though. When I use Firefox or Chrome and download PDF reports from our web application it obviously shows a file download dialog and provides a simple way to visualize the downloaded file (which 90% of the times is the default use case).


With node-webkit it simply downloads to some directory on the machine (the user has chosen) and that's it.

I wonder if there is a way to intercept a download and eventually open the file by default??

Thanks for any help!


VoidVolker

unread,
Mar 31, 2014, 6:05:04 AM3/31/14
to node-...@googlegroups.com
Use event 'onload'.

VoidVolker

unread,
Mar 31, 2014, 6:11:31 AM3/31/14
to node-...@googlegroups.com
Or, you can use node.js functions to get full control of file download. Or some node.js module.

Marc Torruella

unread,
Mar 31, 2014, 6:33:39 AM3/31/14
to node-...@googlegroups.com

Yes i would overwrite the click event on all file links and use nodejs

El dia 31/03/2014 12:11, "VoidVolker" <voidv...@gmail.com> va escriure:
Or, you can use node.js functions to get full control of file download. Or some node.js module.

--
You received this message because you are subscribed to the Google Groups "node-webkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-webkit...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

VoidVolker

unread,
Mar 31, 2014, 6:54:04 AM3/31/14
to node-...@googlegroups.com
Ok, then it's not a problem. Node.js functions have callbacks - use them. Read manual for network and file api.

Juri Strumpflohner

unread,
Apr 1, 2014, 2:57:20 AM4/1/14
to node-...@googlegroups.com
Ok...I'm sorry for my ignorance...but how can I overwrite the click event on all file links with node.js when I'm loading an external web (site/application) from within node-webkit. The site that is being loaded may even contain stuff like

...
window.location.href = '/api/v1/myPdfRenderingEndpoint';
...

..at some point as it is a SPA.

VoidVolker

unread,
Apr 1, 2014, 3:22:15 AM4/1/14
to node-...@googlegroups.com
Then just use filter for this files, what you need. Or use classic callback "onload".

Marc Torruella

unread,
Apr 1, 2014, 3:26:28 AM4/1/14
to node-...@googlegroups.com
you can use an iframe to load the external webpage.
And from outside the iframe, using jquery, access the iframe and overwrite the click event on all links that matches your criteria.

If i'm not wrong, you can bypass the crossdomain security policy in nodewebkit, so it should work


--

Juri Strumpflohner

unread,
Apr 1, 2014, 5:03:00 AM4/1/14
to node-...@googlegroups.com

And from outside the iframe, using jquery, access the iframe and overwrite the click event on all links that matches your criteria

It is impossible to know which link causes a download. We're speaking about a large-scale JavaScript application written with JavaScriptMVC (like Backbone).

Then just use filter for this files, what you need. Or use classic callback "onload".

Sorry, I didn't get what you mean..

Well...as far as I understand there is nothing in node-webkit that would let you intercept a file download as it happens or afterwards, to be able to grab it and somehow do some further work on it...

VoidVolker

unread,
Apr 1, 2014, 6:02:27 AM4/1/14
to node-...@googlegroups.com

Sorry, I didn't get what you mean..

 

Juri Strumpflohner

unread,
Apr 1, 2014, 11:36:20 AM4/1/14
to node-...@googlegroups.com
:) that was quite clear...what I didn't understand is how that would help me in my scenario.

As I mentioned, I cannot do anything like adjusting the URLs or attaching onClick handlers dynamically as I have a large SPA which gets loaded from a remote endpoint...There are no clear links or whatever that would indicate a file download. That's why I asked for a possibility to intercept the download itself..

thx anyway for trying to help.

VoidVolker

unread,
Apr 2, 2014, 11:50:10 PM4/2/14
to node-...@googlegroups.com
I have another idea: use the proxy module for node.js to load all pages from internet and say NW to use it. In this case you get the full control what files NW(user via NW) is loading and it state.
Reply all
Reply to author
Forward
0 new messages