A a static website as a lightweight file server for downloading/uploading files. On the server side, all you need is an nginx executable file. On the client side (mobile or desktop), any brower will work.
- File list: support sorting by name/date.
- Download files.
- Upload files: support uploading multiple files, support selecting destination and creating arbitrary subfolders. Only
tmp(and its subfolders) are writable. You can change the setting in the config file. - Delete files/folders. Only the subfiles/subfolders of
tmpcan be deleted. You can change the setting in the config file. - Read/write text messages.
- Support file names with special characters (
" ' ? * <> \ @ & :...).
-
Download this repository
-
Download nginx from official website and extract the executable file
nginx.exeinto this repository. -
Copy
nginx-standalone-example.conftonginx.conf. -
Run
nginx.bat.
-
Download this repository and install nginx.
-
Prepare the nginx config file: open
nginx-distro-example.conffor reference, and edit/etc/nginx/nginx.confmanually. DON'T replace/etc/nginx/nginx.confwith this file directly. -
The nginx from your distro may run under a different user (e.g.
nginxuser). Make sure it has read access to this repository, and read/write access totmpfolder.
sudo chown nginx:nginx ./tmp
- If your system has SELinux enabled, you need to set
allow_httpd_anon_writeboolean toon, tag this repository topublic_content_t, and tagtmpfolder topublic_content_rw_t:
# Set the boolean
sudo setsebool -P allow_httpd_anon_write on
# Add a permanent rule
sudo semanage fcontext -a -t public_content_t '/absolute/path/to/this/repository(/.*)?'
# Add a permanent rule
sudo semanage fcontext -a -t public_content_rw_t '/absolute/path/to/this/repository/tmp(/.*)?'
# Note: Use -d in place of -a to delete the permanent rules you added
# Apply the SELinux rules
sudo restorecon -Rv path/to/this/repository
- Start nginx
sudo systemctl start nginx
-
Download this repository and install nginx
sudo brew install nginx. -
Prepare the nginx config file: open
nginx-distro-example.conffor reference, and edit/usr/local/etc/nginx/nginx.confmanually. DON'T replace/usr/local/etc/nginx/nginx.confwith this file directly. -
Start nginx
sudo brew services start nginx
nginx typically serves static files and/or act as a reverse proxy. But with dav_methods PUT DELETE option, it can accept PUT and DELETE methods and thus we can upload/delete files. With autoindex on option, nginx can do file-listing. Currently only ./tmp/... accepts PUT and DELETE requests, and GET requests on ./files/... will get a file list.
When handling a PUT request, nginx will create a temp file in client_body_temp_path. If PUT succeeds, the temp file will be moved to the destination. If PUT fails, the temp file will be deleted. So client_body_temp_path should reside on the same disk as the PUT destination. In nginx-standalone-example.conf and nginx-distro-example.conf, this value is set to ./tmp/.nginx/client-body.
Other temp folders and log file locations are set to ./tmp/.nginx/... in nginx-standalone-example.conf. If you are using the nginx from your distro, it's better to use the default settings, so nginx-distro-example.conf doesn't contain such settings (except for client_body_temp_path mentioned above).
Any brower will work. When the brower executes the .js files, it will make GET requests to /files/... to get the file list, then generate the corresponding table shown on the web page. This is a static website, so the server only returns a JSON with the built-in autoindex functionality and everything else is handled by the client.
As for the message functionality: when you write a message, it will simply upload a file ./tmp/.tmp.txt with the message content. When you read a message, it will read the content of ./tmp/.tmp.txt.