Menu

#50 Browse your external HD via webpages

New
nobody
None
Medium
Defect
2013-08-05
2010-08-08
Anonymous
No

Originally created by: pen... (code.google.com)@gmail.com

I made a browser to navigate trough your external hard disk(s), add, delete and download files via a webpage.
This as an alternative to the build-in nas ftp feature but with the advantage that it works always. The disadvantage of ftp is that is blocked on several locations and with some hard disk formats is read-only anyway.
This browser is always read/write. Since this is done via http you can do this from everywhere as long as you can surf on the www. Also note that you may have to configure your router to redirect requests from outside your local network on a specific port (for example 8080) to your nas.

Everything can be found at http://www.peno.be/snake/

What you have to do to make this work is the following:

Configure the snake nas to enable webserver, this via Services, WebServer.
For example:

Web Server folder: /usb/exthd1/web
Enable Web Server: v
Web Server port:   8080   
Web Server status:    WEBSERVER is running

Then in the folder where the webserver is looking into, create folders cgi-bin and img and put there the files from http://www.peno.be/snake/

Now you can navigate to it. For example:

http://snake:8080/cgi-bin/myfilebrowser.cgi

That should give a page with the root of /usb or the external disk(s) connected to the usb port(s) of the nas.
For example:

Current folder: /
.
..
drwxrwxrwx   58 root     root        32768 Jan  1  1970 exthd1

You can click on each directory entry to go into that folder.
. is the current directory and is ment to do a refresh of your current selected folder
.. is going one directory up
and any line beginning with a d is a directory which is selected when you click on it.

At a certain moment you can have something like:

Current folder: /exthd1/WereldDag/c
.
..
drwxrwxrwx    4 root     root        32768 Mar 25  2006 CreateModel
drwxrwxrwx    2 root     root        32768 Mar 25  2006 GenModel
-rwxrwxrwx    1 root     root          960 Mar 13  2004 Model.dsw
-rwxrwxrwx    1 root     root        58368 Mar 15  2004 Model.ncb
-rwxrwxrwx    1 root     root        59904 Mar 15  2004 Model.opt
drwxrwxrwx    4 root     root        32768 Mar 25  2006 ReadModel
-rwxrwxrwx    1 root     root         8115 Mar 15  2004 a.sq
-rwxrwxrwx    1 root     root          168 Mar 15  2004 bak.bat
-rwxrwxrwx    1 root     root         8264 Mar 15  2004 bak.sq
-rwxrwxrwx    1 root     root          961 Mar 15  2004 pe.cfg

+-------------+
| Upload File |
+-------------+

Before each file there is also a trash icon (not shown here above).

Clicking on the trash will give the question if this file may be deleted and when answered positively the file is deleted and a new listing of the current folder is given in which the file should not be there anymore.

Clicking on a line starting with a 'd' (and thus not having a trash icon because removing folders is not implemented will navigate to that folder and give its contents.

Clicking on a line not starting with a 'd', so a file (and thus one having a trash icon) will give you the question if you want to download that file. When answered positively it is downloaded from the external hd, via the webserver on the nas to your local computer.

Below the list there is also a button to upload a file. When this is done a new page is given where you first must browse to a file that you want to upload and when that is done you can click the Upload button to upload this file to the selected folder. When done, the directory listing of the selected folder is given again and that file should be there now. You can also press cancel to return to the listing without uploading.

It would be nice if the authors of the snake OS would add this feature also in the OS, maybe best via an option that is by default unchecked.

Note that as-is, no password is asked when you call this page. There is a good chance that you don't want this because everyone can do this now and that is something you probably don't want.
But also that can be solved.
You must make a telnet connection to the nas, cd to directory /etc and edit webserver.conf, a file that is already there. At the end of the file a line must be added. For example:
/cgi-bin:admin:snake

That will password protect the cgi-bin folder and in this case the name is admin and password is snake, but you can make anything you want for the name/password combination.
Note that you must restart the WebBrowser service when you have made changes to this config file to make it in effect.

Doing this may be somewhat complicated for people, so here a description how to do it:

- run putty. You can do that immediately and without installation from this link: http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
- in the Host Name input you enter snake, the name of your nas or the ip adres of it and then click open. The first time a question may be asked that a security key is missing. Let it add the key
- Then you will get 'login as: '. Enter root
- Then the password will be asked. Enter the roots password. Default is snake
- When successful, a welcome message is displayed with a # prompts and a blinking cursor
- enter the following and press enter: cd /etc
- now enter the following command: vi webserver.conf
- The file is now edited
- Go with the arrow keys to the last line
- press the 'o' key to go into edit mode and add a new line
- enter the line to protect the folder. For example: /cgi-bin:admin:snake
- press the esc button. You are now again out of edit mode as when you started vi
- to save the file, press : and then press w and the enter key
- to quit editing, press : and then press q and the enter key
- to quit the file without saving, press :, then press q! and the enter key
- to reedit the file and make changed enter again the vi webserver.conf command to edit. Press the 'i' key to go into edit mode. You can enter text, delete via backspace and navigate via the arrow keys. To go out of edit mode, press esc. To delete a character when not in edit mode, press the 'x' key.

With this basic tutorial you should be able to do what is needed.

To stop the telnet session, enter the following command after the # prompt: exit

If you have additional questions or suggestions, you can send me a mail at peno@telenet.be

The author is not responsable of any file loss or damage by using this.

Good luck,

Peter

Related

Tickets: #11
Tickets: #121
Tickets: #329
Tickets: #47

Discussion

1 2 3 > >> (Page 1 of 3)
  • Anonymous

    Anonymous - 2010-08-24

    Originally posted by: nileshme... (code.google.com)@gmail.com

    myfilebrowser.cgi can be tweaked so it follows symbolic links.

    Replace the following line
    echo "$(ls -l "${DIR}")" | while read LINE

    with
    echo "$(ls -lL "${DIR}")" | while read LINE

    Cheers,

    Nilesh

     
  • Anonymous

    Anonymous - 2010-08-27

    Originally posted by: pen... (code.google.com)@gmail.com

    Thanks for your updates. I have also a few ones. Especially also look what happens when you click on the create directory and upload file buttons.

     
  • Anonymous

    Anonymous - 2010-08-27

    Originally posted by: nileshme... (code.google.com)@gmail.com

    Nice work. I wonder if we could add the progress bar for uploads.

     
  • Anonymous

    Anonymous - 2010-09-06

    Originally posted by: nileshme... (code.google.com)@gmail.com

    Here is an update so that the browser shows the download progress / what % is downloaded.

     
  • Anonymous

    Anonymous - 2010-09-27

    Originally posted by: nileshme... (code.google.com)@gmail.com

    I have attached a performance tweak using Bash Parameter Expansion instead of piping to cut. When you are browsing the page should load faster now.

    Cheers. Nilesh

     
  • Anonymous

    Anonymous - 2010-09-30

    Originally posted by: pen... (code.google.com)@gmail.com

    Here are the latest files for browsing via webpages. The mouse cursor is now more standard and all comments are taken into it.

    Peter

     
  • Anonymous

    Anonymous - 2010-10-07

    Originally posted by: blueday... (code.google.com)@gmail.com

    Hi,
    Upload files seem limited 2MB max

     
  • Anonymous

    Anonymous - 2010-10-09

    Originally posted by: pen... (code.google.com)@gmail.com

    At the beginning of the file myfilebrowser.cgi there is:

    #!/bin/haserl --upload-limit=200000

    According to http://haserl.sourceforge.net/cgi-bin/haserl/wiki/read?page=manpage-dev this should mean that the upload limit is 200000 KB which is 200 MB and not 2 MB as you suggest. The problem is that you can't delete that option or set a value to 0 to indicate unlimited upload size.

    On the other hand on https://forum.openwrt.org/viewtopic.php?pid=50849 I read:

    The haserl source currently limits uploads to 2MB, so ...

    And I read simular things on other pages also so I am afraid that is a limit of the shell ...

     
  • Anonymous

    Anonymous - 2010-11-21

    Originally posted by: allst... (code.google.com)@gmail.com

    First of all, thanks. This browser is great.
    But I have one question. I want to create 3 different users and passwords to access to the same folder but I don´t know how to implement this in the webserver.conf file.
    I tried with:
    folder:user1:pass1,user2:pass2
    folder:user1,user2:pass1,pass2
    folder:user1:pass1 user2:pass2
    and some others, but no one works.

    Could you please explain me how?

    Ciao!

     
  • Anonymous

    Anonymous - 2011-01-01

    Originally posted by: F.Com... (code.google.com)@gmail.com

    I would also need to create more user be addressed in different directory .. you can do this?
    sorry for my English! ;)

     
  • Anonymous

    Anonymous - 2011-01-01

    Originally posted by: F.Com... (code.google.com)@gmail.com

    wondering if you could have 5 in each user directory different from ADDRESS
    example: user-Joseph psw:pippo
              user-David psw:Mayor
              user-Mario psw:1234
              user-Louis psw:4321
              user-Gigi psw:pawel

    entering webserver (myfilebrowser.cgi) with user:admin psw:Giuse are all addressed in sda1
    I have 5 in sda1 directory but I can not associate with each its own directory,
    sda1 to enter user:admin psw:Giuse

    the version is: Kernel version: 2.6.16-gazineu
    NAS version: SNAKE OS V1.3.2 (20101130)
    nas bt650

    OS Windows 7
    thanks!

     
  • Anonymous

    Anonymous - 2011-01-01

    Originally posted by: pen... (code.google.com)@gmail.com

    In webserver.conf you specify which users can access the files on the web server. Ie the cgi files that implement the browsing possibilities.
    You don't specify access to files on the usb drive and I am pretty sure that that is not possible.

    The only possibilities I see to make possible what you want is adapting the code of myfilebrowser.cgi
    I see 2 possibilities for this:
    1) In cgi-bin, create a subfolder per user and in that folder put modified versions of myfilebrowser.cgi that only browse the folders that they may see. In webserver.conf you put the folders with the users that can access them.
    2) Or probably better, adapt myfilebrowser.cgi that it reads a file with user/folder info where you define if that user can read that folder and if not, don't display its contents. I think it is doable.

    Peter

     
  • Anonymous

    Anonymous - 2011-03-10

    Originally posted by: mauro.pi... (code.google.com)@gmail.com

    This is a simple HTML redirection to be placed under the folder "/usb/exthd1/web".
    It allows you to call the service simply using:

    http://<nas-address>:<port>

    I hope it could be useful :)

      Mauro

     
  • Anonymous

    Anonymous - 2011-05-19

    Originally posted by: robertoy...@robertoyoldi.com

    Anyone finded a way to upload files bigger than 2MB?

    Thanks!

     
  • Anonymous

    Anonymous - 2011-05-19

    Originally posted by: pepe.j... (code.google.com)@gmail.com

    Have you tried ftp?

    Or

    SCP / SFTP?

    Example for windows
    http://winscp.net/

    And for linux
    scp and sftp

     
  • Anonymous

    Anonymous - 2011-05-19

    Originally posted by: robertoy...@robertoyoldi.com

    Thanks Pepe (Estás en todas...)
    but sometimes I need to upload files from my office or other computers without ftp software or behind a proxy with only the port 80 open.
    I need any kind of web based interface to upload the files. This cgi is great, but with limited file size.

     
  • Anonymous

    Anonymous - 2011-05-21

    Originally posted by: can-tez...@hotmail.com

    Hello everybody!

    Good news! I have a solution for this 2Mb upload file size limitation.

    Cause: When you are uploading a file to your nas system, it uses its memory to save the uploaded file temporarily during this process. So, the max file size is limited to your free memory size at that time. That is the real problem with "haserl".

    Solution: Add "--upload-dir=/usb/sda1" to the end of the first line of your "myfilebrowser.cgi". If your disk name is different than sda1, then use your disk name instead sda1. After this change restart your webserver and try it out. Please keep in mind that with this change the max. uploaded file size can be the half of the free space of your device.

    Enjoy!

     
  • Anonymous

    Anonymous - 2011-05-21

    Originally posted by: pepe.j... (code.google.com)@gmail.com

    Thanks!, It works fine!

     
  • Anonymous

    Anonymous - 2011-09-18

    Originally posted by: v...@kc.rr.com

    A couple of minor tweaks:

    Added "-h" for "human-readable file sizes" - I have very large video files which were not handled correctly by the underlying "ls" command, causing them to overflow the size column, so the links were being mangled by the cut commands. I also feel the human-readable output is preferable anyway.

    Added the style command "img {vertical-align: text-top }" in the header, which causes the icons to line up better vertically, and produces a more concise listing.

    NOTES:

    -- The attached file was edited from the attachment to Comment 7 above, so includes the earlier fixes.

    -- It also includes the "--upload-dir=/usb/sda1" command line option, as suggested in Comment 22 above, so if your drive is not attached as "sda1" you will need to change this to the correct value.

     
  • Anonymous

    Anonymous - 2011-10-23

    Originally posted by: stefansc...@googlemail.com

    I've created an opk package of myfilebrowser:

    https://code.google.com/p/snake-os/downloads/detail?name=myfilebrowser.opk

    Once installed the browser will be available at port 8081. There's currently no configuration.

    User/Password will be the same as the for the snake os web interface.
    NOTE: The password will be stored on the package disk. So somebody could say "borrow" the usb stick and get your password. keep that in mind if you want to try this. I'll look into a better to handle this.

    I've put the package sources in svn I hope that's ok. http://snake-os.googlecode.com/svn/packages/myfilebrowser/

     
  • Anonymous

    Anonymous - 2011-10-24

    Originally posted by: stefansc...@googlemail.com

    oups.. "a better way to handle this"

    The version in the package also runs from a seperate httpd instance so the normal webserver service will still be usable.

     
  • Anonymous

    Anonymous - 2011-10-25

    Originally posted by: dwmcqu... (code.google.com)@gmail.com

    Perfect structure in the SVN, stefan!

     
1 2 3 > >> (Page 1 of 3)

Log in to post a comment.

MongoDB Logo MongoDB