Add inline download management to your Nightmare scripts.
If you need to manage multiple downloads at the same time or want downloads to be processed in the background, check out the Nightmare download manager.
Require the library: and pass the Nightmare library as a reference to attach the plugin actions:
var Nightmare = ;Nightmare;
... and that's it. You should now be able to handle downloads.
Allows for downloads to be saved to a custom location or cancelled. The possible values for
'continue' for default behavior, or a file path (file name and extension inclusive) to save the download to an alternative location. If yielded upon,
.download() returns a hash of download information:
- filename: the filename the server sent.
- mimetype: the mimetype of the download.
- receivedBytes: the number of bytes received for a download.
- totalBytes: the number of bytes to expect if
Content-lengthis set as a header.
- url: the address of where the download is being sent from.
- path: specifies the save path for the download.
- state: the state of the download. At yield,
Additional Nightmare Options
Defines whether or not all downloads should be ignored.
Sets the maximum time for the client to anticipate a
.download() call. If the call is not made, the download is automatically cancelled.
Sets the Electron path for where downloads are saved.
var Nightmare = ;Nightmare;var nightmare = ;var downloadInfo = nightmare;// ... do something with downloadInfo, in an evaluate for example ...;