From bb3716fd57bae508efaea6d5395644b4b97cfd71 Mon Sep 17 00:00:00 2001 From: hamza zia Date: Wed, 29 Apr 2015 23:29:08 +0800 Subject: [PATCH] updated docs for DirectURL --- README.md | 2 +- directurl.md | 60 ++++++++++------------------------------------------ 2 files changed, 12 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 90e6388..fd1a86d 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Read and edit [configuration.js](configuration.js). DirectURL --------- -If you are familiar with how webservers work, setup a location that points at the configured download directory, check permissions. Specify a full url: ```http://server:port/``` +This feature allows users to download files that they download from aria2 directly from the webui dashboard. If you are familiar with how webservers work, setup a http server that points at the configured aria2 download directory, check permissions. Then Specify a full url: ```http://server:port/``` in the webui directURL configuration. If the above is not obvious, keep reading what this is about in [directurl.md](directurl.md) diff --git a/directurl.md b/directurl.md index 4d6ebe1..7219aed 100644 --- a/directurl.md +++ b/directurl.md @@ -7,58 +7,20 @@ Consider the following scenarios: HTTP to the rescue, already in the browser right? -Simplest way is to use a straightforward Node.js library. In the below complete prescription [send](https://github.com/pillarjs/send) will be used. - -Requirements ------------- -Node.js & NPM - -Follow relevant section: [Installing Node.js via package manager](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager) +Simplest way is to use python to setup a http server. Steps ----- 1. as part of configuring aria2 to make life easier you will have set the global **dir** option to something like **/home/aria2/downloads** -2. clearly this folder is owned by the user **aria2** +2. clearly this folder is owned by the user **aria2** 3. open a shell session logged in as **aria2** 4. run ```cd /home/aria2/downloads``` -5. run ```npm install send``` -6. run ```nano send.js``` or vi if that's your thing -7. paste the content from below **send.js** -8. save the file making changes where appropriate _(follow the comments)_ -9. run ```node send.js``` -10. webserver is now running on port 3000 and will serve files from the directory specified -11. to test open up http://serverip:3000 - should get a response from the webserver, 2 lines of text, any browser errors and something hasn't been done properly, check IP/PORT etc -12. go back to webui-aria2 -13. go to ```Settings > Connection Settings``` -14. scroll down to Direct Download and put ```http://serverip:3000/``` in base URL field _(make sure have the / on the end)_ -15. now that URL has been specified all the files will be converted into clickable links -16. checkout the ```more info``` on a download and see for yourself -17. if you click on files that aren't finished downloading ```you're going to have a bad day``` - -### send.js - -```js -var http = require('http'); -var send = require('send'); -var url = require('url'); - -var app = http.createServer(function(req, res){ - // this one allows the service to fail gracefully and give some feedback - function error(err) { - res.statusCode = err.status || 500; - res.end(err.message); - } - - // this just makes sure everything is downloaded and not opened in the browser - function headers(res, path, stat) { - res.setHeader('Content-Disposition', 'attachment'); - } - - // specify the same directory that aria2 is using to save files - // not sure exactly how windows paths should be done, see if 'c:\downloads' works.. - send(req, url.parse(req.url).pathname, {root: '/home/aria2/downloads'}) - .on('error', error) - .on('headers', headers) - .pipe(res); -}).listen(3000); // change this to .listen(3000,'127.0.0.1') to only respond to localhost requests then access via SSH tunnel or put stunnel in front of it etc -``` \ No newline at end of file +5. run ```python -m SimpleHTTPServer 8080``` +6. webserver is now running on port 8080 and will serve files from the directory specified +7. to test open up http://serverip:8080 - should get a response from the webserver, 2 lines of text, any browser errors and something hasn't been done properly, check IP/PORT etc +8. go back to webui-aria2 +9. go to ```Settings > Connection Settings``` +10. scroll down to Direct Download and put ```http://serverip:8080/``` in base URL field _(make sure have the / on the end)_ +11. now that URL has been specified all the files will be converted into clickable links +13. checkout the ```more info``` on a download and see for yourself +14. if you click on files that aren't finished downloading ```you're going to have a bad day``