Delta - file uploader + url shortner
delta is a small hobby project that I did in my free time. It's a self-hosted file uploader + URL shortner. In short, you can fire a simple curl command with a file name, and that file will be uploaded to your server, after that you'll have a short url as a reponse of upload. And you can use this URL to fetch the uploaded file. Same goes with URL shortner
Demo
Features
- File uploader backed with Superfast Expressjs and Multer
- URL shortener for files (upload file = get shortened URL in return)
- URL shortener for long URLS (
http://example.com/games/minecraft/world=http://sma.ll/6Tj) - Custom URL support (
http://example.com/longurl/school/college/work=http://sma.ll/life) - Secured with API keys
- Multiuser + Multidomain support on the same server (see this)
- Configurable Cron job for deleting resources older than X time
- Never Clashing (0% collision guaranteed) Permanent ID's for generated URLs.
- self destructing links
- Password protected links
- Easy to install, setup and use :P
Installation
Clone
git clone https://github.com/fosslife/delta.git
Or, download zip from master branch
Configuration
Open config.js. it has multiple things you need to configure
users: list of users with their own api-keys, name etc.name: Name of the user, a folder will be created with this name inside upload directory.apiKey: a random long string (mandatory as user identification is done with this key, can't leave empty)- run
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1ORdate | md5sum | base64 | head -c 32to create one domainUrl: 'https://your.domain.url/'Keep the trailing slash/
timeZone: 'Your/Timezone' This is used to run the cron job periodically according to your locationuploadpath: Absolute path where you want your files to be stored on servercron:schedule: Cron schedule string, default is 1st Day of every month at 00:00min_age: Minimum time (days) for which file should be retainedmax_age: Maximum time (days) for which file should be retainedmax_size: Maximum file size to calculate retaintion period against (it's not max size of file to upload)
dbconfig: Redis configurationport: Redis server porthost: Set via REDIS_HOST env variable for Docker, give your server URL if you are not using dockerpassword: Server password
port: Port at which you want to run delta aturlLength: length of the generated URL, 4 to 7 are considered good.urlString: list of characters from which shortened URL is generated, you can remove I,l,4,A etc look-alike characters if you want
Install dependencies
There are two ways to use delta
- docker method and
- non-docker(direct) method
Docker
| although I have created basic Dockerfile and docker-compose.yml, and it works, I don't know much docker I need help with persistance storage/volume etc. If you know Docker, that'd be a great help :)
Redis
Debian/Ubuntu etc
sudo apt-get install redis-server
sudo systemctl enable --now redis-server.service
fedora etc
sudo dnf -y install redis
sudo systemctl enable --now redis
| for other OS: https://www.google.com/search?q=install+redis+on+my+os
Node
npm install # or yarn install
Enjoy
- run
npm startoryarn start! Server is started, enjoy!
If ther's something not working, please submit an issue, I will make sure I fix it in upcoming weekend :D
Usage
If you have installed everything correctly, and server is working it's really easy to use it.
curl Method
Most basic method, and it will work with just simple curl command or alternative.
for files
- Go to the directory from which you want to upload the file
- run
curl -H 'api-key: API_KEY' -F file=@filename https://url.com/, - Replace required data accordingly
- API_KEY - The exact key you have given on server in
config.json - filename - filename you want to upload
- API_KEY - The exact key you have given on server in
for urls
- Just replace
-F file=@filenamepart with-d 'url=http://google.com/. Rest of the command stays same - To generate custom URLs add
-d 'custom=test'with previous command
See Examples for more details.
Examples and API
Considering apiKey = 1234:
- To upload a file called dogs.jpg
curl -H 'api-key: 1234' -F file=@dogs.jpg http://url.com/