-
Notifications
You must be signed in to change notification settings - Fork 26
/
welcome.txt
128 lines (88 loc) · 5.52 KB
/
welcome.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
**********************************************
############# DELTA ######################
**********************************************
`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` or any other equivalent 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.
Ex: if you upload your `user_environment.conf` to server, you'll have
something like `sma.ll/y7A` in return (where `sma.ll` is your server).
After than anyone with the URL (optionally password), can access this
file with a simple `GET` request, even from browser.
## Demo
https://asciinema.org/a/0e4sjjrPoEMq9uu8FIYSdNwsD
## Features
- File uploader backed with Superfast Expressjs
- 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](#multiuser))
- Configurable Cron job for deleting resources older than X time
- "Never Clashing" Permanent ID's for generated URLs. they are not random,
but infact incremental so no worries of clashing two URLs and also URLs
are non back traceable, i.e. URL generator shuffles them randomly everytime server starts.
- Coming
- password protection
- file encryption
## Installation
The module is a simple express server with some configuration. To set it up follow the steps:
#### Checkout project
- `git clone https://github.com/fosslife/delta.git` OR
- Download zip from [master](https://github.com/fosslife/delta/archive/master.zip) branch
#### Configuration
- apiKey : 'RANDOM_LONG_STRING'
To generate a random string, you can run
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
or date | md5sum | base64 | head -c 32
- domainUrl: 'https://your.domain.url/' Keep the trailing slash `/`
- timeZone: 'Your/Timezone' This is used to run the cron job periodically according to your location
#### Install dependencies
- Run `npm install` or `yarn install` or your favourite other tool :P
#### Enjoy
- Server is started, enjoy!
## 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
##### for urls
- Just replace `-F file=@filename` part 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](#examples) for more details.
## Examples
Considering apiKey = 1234:
- To upload a file called dogs.jpg
⇒ curl -H 'api-key: 1234' -F [email protected] http://url.com/
- To shorten a URL, say this repository
⇒ curl -H 'api-key: 1234' -d 'url=https://github.com/fosslife/delta.git' http://url.com/
- To shorten custom URL, again this repository, to `delta`
⇒ curl -H 'api-key: 1234' -d 'url=https://github.com/fosslife/dekta.git' -d 'custom=dlta' http://url.com/
## Multiuser
delta is a private file uploader, and it's supposed to be used for personal use only. Unlike many other famous file uploaders it's not open to all. for that purpose, you can just keep your API key simple like `a` or something and distribute it publicly somewhere so that everyone can use your servers instance.
But what if you don't want to distribute your api key but still let other people use the server? what if each users data is supposed to be stored in different directory? what if other users don't want your hostname in return but something different?
:grin: delta supports all of it. `multiuser` branch lets you host delta for multiple users on the same instance. just edit the given `config.json` and you are good to go. The structure of `config.json` is a littlebit different than that of master branch
- Everything is inside a `users` array
- First element represents the name of the user.
- this will be used to create different directories to store the uploaded files for each user.
- keep this parameter same for those users you want to store files in the same directory
- Second parameter is apiKey, this can be different for each user
- third paramter is the server name which will be returned as a short URL as a response.
Example:
this is current configuration:
{
users: [
['Spark', 'spark1234', 'https://i.spark.pepe/'],
['John', '1234John', 'https://john.meme/']
];
}
And, If spark makes a request to the server with his own api key, the server will store the uploaded file inside a different dir called `spark` in `uploads/` folder, and will return `https://i.sprk.pw/7HgY` as shortened URL, but if John makes a request to same server with his private api key, his files will be stored in `John` directory under `uploads/` folder, and he will get `https://john.meme/8Hy` in return :)
## Licence
delta is Licensed under [MIT](https://github.com/fosslife/sprk/blob/master/LICENSE)