Js project to create a temporary link to download a file
Find a file
2025-08-02 21:25:18 +03:00
.github/workflows [f] fix tags 2025-04-03 22:40:23 +03:00
src [r] rename 2025-08-02 21:25:18 +03:00
.gitignore [+] ignore file 2025-04-01 21:09:17 +03:00
dockerfile [+] add dockerfile 2025-04-01 22:01:26 +03:00
index.js [r] refactor 2025-04-05 00:54:48 +03:00
package-lock.json [+] add dotenv 2025-04-05 00:54:55 +03:00
package.json [+] add dotenv 2025-04-05 00:54:55 +03:00
readme.md [r] rename 2025-08-02 21:25:18 +03:00

temp-file-sharing

A simple Node.js-based temporary file sharing service, similar to dropmefiles. Users can upload files via drag & drop, file selection, or clipboard paste. A unique download link is generated for each file, which is available for a configurable retention period before the file is automatically deleted. An anti-spam mechanism limits the number of uploads per IP, and once a file is uploaded, further uploads are disabled until a page refresh.

Initial Setup

  1. Clone the repository: Clone this repository using git clone.
  2. Download Dependencies: download dependencies using npm.
git clone https://github.com/ergolyam/temp-file-sharing
cd temp-file-sharing
npm install

Deploy

  • Run:

    npm start
    
  • Other working env's:

    PORT=3000
    FILE_RETENTION="30"
    FILE_SIZE_LIMIT="10"
    PUBLIC_DOMAIN="example.com"
    UPLOAD_LIMIT="5"
    

Container

  • Pull container:

    podman pull ghcr.io/ergolyam/temp-file-sharing:latest
    
  • Deploy in container

    podman run --tmpfs /tmp -d \
    --name temp-file-sharing \
    -p 3000:3000 \
    -e PORT="3000" \
    ghcr.io/ergolyam/temp-file-sharing:latest
    

Proxy on nginx

Routing Based on Hostname

  • Create a file /etc/nginx/sites-enabled/example.com with the lines:
    server {
        listen 80 default;
        server_name example.com;
    
        location / {
            proxy_pass http://127.0.0.1:3000/;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            client_max_body_size 0;
        }
    }
    

Routing Based on URL Path

  • Create a file /etc/nginx/sites-enabled/example.com with the lines:
    server {
        listen 80 default;
        server_name example.com;
    
        location /shared/ {
            proxy_set_header X-Forwarded-Prefix /shared;
            proxy_pass http://127.0.0.1:3000/;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            client_max_body_size 0;
        }
    }
    

Features

  • Multiple Upload Methods:
    Drag & drop, file selection, and clipboard paste support.

  • Temporary File Storage:
    Files are stored in /tmp/temp-files and automatically deleted after a configurable retention period.

  • Download Link Generation:
    Each upload generates a unique download link.

  • Anti-Spam Protection:
    Limits the number of uploads from a single IP within a 5minute window. Excessive uploads result in a temporary block.

  • Proxy Friendly:
    Supports Nginx proxy configuration by using app.set('trust proxy', true) and the PUBLIC_DOMAIN environment variable.

  • Client UI:
    Once a file is uploaded, the drag & drop zone is removed and the download link along with the original file name is displayed.