https://github.com/adridevelopsthings/hastebin
A minimalistic hastebin server
https://github.com/adridevelopsthings/hastebin
Last synced: about 1 year ago
JSON representation
A minimalistic hastebin server
- Host: GitHub
- URL: https://github.com/adridevelopsthings/hastebin
- Owner: AdriDevelopsThings
- License: agpl-3.0
- Created: 2024-01-08T00:51:22.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-04T22:26:21.000Z (over 2 years ago)
- Last Synced: 2025-02-10T21:53:12.778Z (over 1 year ago)
- Language: Rust
- Homepage: https://haste.adridoesthings.com
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hastebin
## Installation
### Docker
Just pull the docker image:
```
docker pull ghcr.io/adridevelopsthings/hastebin:main
```
and run the docker image:
```
docker run --name hastebin -d -p 80:80 -v ./data:/data ghcr.io/adridevelopsthings/hastebin:main
```
### Build it yourself
Build a binary with cargo yourself:
```
cargo build --release
```
## Configuration
Configure your hastebin instance with environment variables:
- `LISTEN_ADDRESS`: default=`127.0.0.1:8000`, docker default=`0.0.0.0:80`
- `DATA_DIRECTORY`: path to the directory where the uploaded files should be stored, default=`data`, docker default=`/data`
- `MAX_FILE_SIZE`: maximum size a file can have, default=`1048576` (1 MB)
- `AUTO_DELETE_CHECK_INTERVAL`: in seconds, default=`120`
- `AUTO_DELETE_OLDER_THAN`: files older than this duration will be deleted (set this value to 0 to disable auto deletion), default=`172800`(2 days)
- `ID_LENGTH`: the length a generated file id should have, default=`10`
- `CHANGE_KEY_LENGTH`: the length a change key should have, default=`64`
## Endpoints
### Static endpoints
`/index.html` and `/*/*` will return a html file. `/index.js` will return a javascript file.
### Api endpoints
- *Getting the content of a file* Make a GET request to `/api/file//` and you will get the file with a guessed mime type or a 404 error.
- *Creating a new file* Make a POST request to `/api/file/` and put the content in the body and you will get json that looks like this: `{"id": "file_id", "change_key": "change_key"}` back. If your uploaded file is too big an error 400 with the body `File is too big` will be responded.
- *Modifying a file* Make a PUT request to `/api/file//`, put the content in the body and set the `Change-Key` header to your change key. If the modification was successfull a status 204 will be responded. If your uploaded file is too big an error 400 with the body `File is too big` will be responded. If your change key is invalid an error 403 with the body `Invalid change key` will be responded.
- *Deleting a file* Make a DELETE request to `/api/file//` and set the `Change-Key` header to your change key. If the deletion was successfull a status 204 will be responded. If your change key is invalid an error 403 with the body `Invalid change key` will be responded.