webpage.onFileDownload = function(url) {
return "filename";
}
webpage.onFileDownloadError = function(errorMessage) {
console.log(errorMessage)
}--
You received this message because you are subscribed to the Google Groups "phantomjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phantomjs+...@googlegroups.com.
Visit this group at http://groups.google.com/group/phantomjs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
*Comments/Questions:*
1. Awesome, you rock!
2. Regarding the filename to be returned:
* Does it save to a particular folder (e.g. a "downloads" folder
to be configured at the command line)?
* Does it save relative to the current working directory?
* Can I return an absolute path to make it save somewhere
specific regardless of the answers to the above two questions?
3. I'm assuming that when we enable the ability to read data from
HTTP responses (i.e. in `onResourceReceived`) that people would
also want to be able to do the same to inspect/read download
responses rather than always having to save them. Will that be a
feasible possibility with the current implementation, or will we
always have to save to file first?
Sincerely,
James Greene
On Thu, May 2, 2013 at 7:49 AM, Vitaliy Slobodin
<vitaliy....@gmail.com <mailto:vitaliy....@gmail.com>> wrote:
Hi guys,
I finished a new feature for file downloading.
& nbsp; *What's inside:*
Two new callbacks for the WebPage:
1) onFileDownloadError - invokes when error has been occurred
while downloading a file
2) onFileDownload - invokes when a web servers' response includes
a "Content-Disposition" header with the "attachment" directive.
How it looks in action:
||
webpage.onFileDownload =function(url){
return"filename";
}
The 'url' argument is a full link to the downloading file.
This callback must return a string value which indicates where
PhantomJS should save a file. If user wants to abort downloading,
he should return an empty string.
---
||
webp age.onFileDownloadError =function(errorMessage){
console.log(errorMessage)
}
This callback raises when PhantomJS was unable to download file.
This callback will not be raised if error is network related (in
this case our standard onResourceError callback will be called).
Comments, thoughts, ideas?
Thanks,
Vitaliy.
--
You received this message because you are subscribed to the Google
Groups "phantomjs" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to phantomjs+...@googlegroups.com
&nbs p; <mailto:phantomjs%2Bunsu...@googlegroups.com>.
Thanks for the new feature, it sounds good. Is there any way to read
more information about the file inside the callback? For instance,
file's size using 'Content-Length' header, mime type and such.
2013/5/2 James Greene <james.m...@gmail.com
<mailto:james.m...@gmail.com>>
*Comments/Questions:*
1. Awesome, you rock!
2. Regarding the filename to be returned:
* Does it save to a particular folder (e.g. a "downloads"
folder to be configured a t the command line)?
* Does it save relative to the current working directory?
* Can I return an absolute path to make it save somewhere
specific regardless of the answers to the above two questions?
3. I'm assuming that when we enable the ability to read data from
HTTP responses (i.e. in `onResourceReceived`) that people
would also want to be able to do the same to inspect/read
download responses rather than always having to save them.
Will that be a feasible possibility with the current
implementation, or will we alway s have to save to file first?
Sincerely,
James Greene
On Thu, May 2, 2013 at 7:49 AM, Vitaliy Slobodin
<vitaliy....@gmail.com <mailto:vitaliy....@gmail.com>>
wrote:
Hi guys,
I finished a new feature for file downloading.
*What's inside:*
Two new callbacks for the WebPage:
1) onFileDownloadError - invokes when error has been occurred
while downloading a file
2) onFileDownload - invokes when a web servers' response
&nb sp; includes a "Content-Disposition" header with the "attachment"
directive.
How it looks in action:
||
webpage.onFileDownload =function(url){
return"filename";
}
The 'url' argument is a full link to the downloading file.
This callback must return a string value which indicates where
PhantomJS should save a file. If user wants to abort
downloading, he should return an empty string.
---
||
& nbsp; webpage.onFileDownloadError =function(errorMessage){
console.log(errorMessage)
}
This callback raises when PhantomJS was unable to download file.
This callback will not be raised if error is network related
(in this case our standard onResourceError callback will be
called).
*Branch:*
https://github.com/Vitallium/phantomjs/tree/download-support
Comments, thoughts, ideas?
Thanks,
Vitaliy.
--
You received this message because you are subscribed to the
Google Groups "phantomjs" group.
To unsubscribe from this group and stop receiving emails from
it, send an email to phantomjs+...@googlegroups.com
<mailto:phantomjs%2Bunsu...@googlegroups.com>.
Visit this group at
http://groups.google.com/group/phantomjs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google
Groups "phan tomjs" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to phantomjs+...@googlegroups.com
<mailto:phantomjs%2Bunsu...@googlegroups.com>.
What happens if a download is triggered but this callback is not
setup? I'm assuming PhantomJS will ignore it rather automatically
downloading it to a Downloads/CWD folder using the filename that
Content-Disposition header suggests (auto-saving files like that could
get pretty sketchy security-wise).
Sincerely,
James Greene
On Thu, May 2, 2013 at 11:50 AM, Vasiliy P <vas...@hotger.com
<mailto:vas...@hotger.com>> wrote:
Thanks for the new feature, it sounds good. Is there any way to
read more information about the file inside the callback? For
&n bsp; instance, file's size using 'Content-Length' header, mime type and
such.
2013/5/2 James Greene <james.m...@gmail.com
<mailto:james.m...@gmail.com>>
*Comments/Questions:*
1. Awesome, you rock!
2. Regarding the filename to be returned:
* Does it save to a particular folder (e.g. a
"downloads" folder to be configured at the command line)?
* Does it save relative to the current working directory?
&nb sp; * Can I return an absolute path to make it save
somewhere specific regardless of the answers to the
above two questions?
3. I'm assuming that when we enable the ability to read data
from HTTP responses (i.e. in `onResourceReceived`) that
people would also want to be able to do the same to
inspect/read download responses rather than always having
to save them. Will that be a feasible possibility with
  ; the current implementation, or will we always have to save
to file first?
Sincerely,
James Greene
On Thu, May 2, 2013 at 7:49 AM, Vitaliy Slobodin
<vitaliy....@gmail.com
<mailto:vitaliy....@gmail.com>> wrote:
Hi guys,
I finished a new feature for file downloading.
*What's inside:*
& nbsp; Two new callbacks for the WebPage:
1) onFileDownloadError - invokes when error has been
occurred while downloading a file
2) onFileDownload - invokes when a web servers' response
includes a "Content-Disposition" header with the
"attachment" directive.
How it looks in action:
||
webpage.onFileDownload =function(url){
return"fi lename";
}
The 'url' argument is a full link to the downloading file.
This callback must return a string value which indicates
where PhantomJS should save a file. If user wants to abort
downloading, he should return an empty string.
---
||
webpage.onFileDownloadError =function(errorMessage){
console.log(errorMessage)
}
This callback raises when PhantomJS was unable to download
file.
This callback will not be raised if error is network
related (in this case our standard onResourceError
callback will be called).
*Branch:*
https://github.com/Vitallium/phantomjs/tree/download-support
Comments, thoughts, ideas?
&nbs p; Thanks,
Vitaliy.
--
You received this message because you are subscribed to
the Google Groups "phantomjs" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to
phantomjs+...@googlegroups.com
<mailto:phantomjs%2Bunsu...@googlegroups.com>.
Visit this group at
http://groups.google.com/group/phantomjs?hl=en.
For more options, visit
https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the
Google Groups "phantomjs" group.
To unsubscribe from this group and stop receiving emails from
it, send an email to phantomjs+...@googlegroups.com
<mailto:phantomjs%2Bunsu...@googlegroups.com>.
Visit this group at
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google
Groups "phantomjs" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to phantomjs+...@googlegroups.com
<mailto:phantomjs%2Bunsu...@googlegroups.com>.
Visit this group at http://groups.google.com/group/phantomjs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google
Groups "phantomjs" group.
To unsubscribe from this group and stop receiving emails from i t, send
Thanks for adding this feature, I think this is what I have been
looking for!
I am trying to download a pdf file which is accessed by clicking a
form button; the filename and download url are unknown.
With your version of PhantomJS, after I click the download button, the
onFileDownload function is triggered which is the desired effect, but
the download fails. onFileDownloadError produces no error.
The URL provided to the onFileDownload function is the URL of the form
I just clicked, while I was expecting the URL of the file being pushed
to me.
Any suggestions how to download such a file, or how to debug this
download problem would be much appreciated.
Thanks,
Patrick
On Thursday, May 2, 2013 8:49:54 AM UTC-4, Vitaliy Slobodin wrote:
Hi guys,
I finished a new feature for file downloading.
*What's inside:*
Two new callbacks for the WebPage:
1) onFileDownloadError - invokes when error has been occurred
while downloading a file
2) onFileDownload - invokes when a web servers' response includes
a "Content-Disposition" header with the "attachment" directive.
How it looks in action:
||
webpage.onFileDownload =function(url){
return"filename";
}
The 'url' argument is a full link to the downloading file.
&nbs p; This callback must return a string value which indicates where
PhantomJS should save a file. If user wants to abort downloading,
he should return an empty string.
---
||
webpage.onFileDownloadError =function(errorMessage){
console.log(errorMessage)
}
This callback raises when PhantomJS was unable to download file.
This callback will not be raised if error is network related (in
this case our standard onResourceError callback will be called).
<https://github.com/Vitallium/phantomjs/tree/download-support>
Comments, thoughts, ideas?
Th anks,
The problem in my case was that the path and filename assigned to the file get 'mangled' which causes the file to be stored in unexpected places.After clicking a download url in the format of "/docviewer.aspx?keyid=dmWHxTXXXXXLI1lRULBT+5l7y+XXXXXXXXXXXXXXXXXXn+4UEjwZ4muZ9aXXXXXXXXX2/td99G/Lf+y2XRHK4wQ==", I end up with a file named "Lf+y2XRHK4wQ=="If I return an absolute path from onFileDownload (/some/path/to/download), the file "Lf+y2XRHK4wQ==" will be stored as /some/path/toLf+y2XRHK4wQ==. Relative paths produce different results.
The filename seems to be derived from the URL instead of the content-disposition header.
I implemented using the Content-Disposition header in a branch where I rebased Vitaliy's commits.[1]