breeze/README.md

152 lines
5.0 KiB
Markdown
Raw Permalink Normal View History

2023-02-01 19:25:38 -06:00
# breeze
2023-06-13 18:24:37 -05:00
breeze is a simple, performant file upload server.
2023-02-01 19:25:38 -06:00
2023-12-08 13:17:19 -06:00
The primary instance is https://picture.wtf.
2023-02-01 19:25:38 -06:00
## Features
Compared to the old Express.js backend, breeze has
- Streamed uploading
- Streamed downloading (on larger files)
- Upload caching
- Generally faster speeds overall
2024-05-25 00:21:36 -05:00
- Temporary uploads
- Automatic exif data removal
2023-02-01 19:25:38 -06:00
At this time, breeze does not support encrypted uploads on disk.
## Installation
I wrote breeze with the intention of running it in a container, but it runs just fine outside of one.
Either way, you need to start off by cloning the Git repository.
```bash
2023-11-10 18:36:43 -06:00
git clone https://git.min.rip/min/breeze.git
2023-02-01 19:25:38 -06:00
```
2023-12-08 13:17:19 -06:00
To run it in Docker, I recommend using Docker Compose. An example `docker-compose.yaml` configuration is below. You can start it using `docker compose up -d`.
2023-06-13 18:24:37 -05:00
```
version: '3.6'
services:
breeze:
build: ./breeze
restart: unless-stopped
volumes:
- /srv/uploads:/data
2023-12-08 13:17:19 -06:00
- ./breeze.toml:/etc/breeze.toml
2023-06-13 18:24:37 -05:00
2024-05-25 00:47:08 -05:00
user: 1000:1000
2023-06-13 18:24:37 -05:00
ports:
2024-05-25 00:21:36 -05:00
- 8383:8000
2023-02-01 19:25:38 -06:00
```
2023-12-08 13:17:19 -06:00
For this configuration, it is expected that:
2024-05-25 00:21:36 -05:00
* there is a clone of the Git repository in the `./breeze` folder
2023-12-08 13:17:19 -06:00
* there is a `breeze.toml` config file in current directory
* there is a directory at `/srv/uploads` for storing uploads
2024-05-25 00:21:36 -05:00
* port 8383 will be made accessible to the Internet somehow (either forwarding the port through your firewall directly, or passing it through a reverse proxy)
2024-05-25 00:47:08 -05:00
* you want the uploads to be owned by the user on your system with id 1000. (this is usually your user)
2023-02-01 19:25:38 -06:00
2023-06-13 18:24:37 -05:00
It can also be installed directly if you have the Rust toolchain installed:
2023-02-01 19:25:38 -06:00
```bash
cargo install --path .
```
## Usage
### Hosting
2023-12-08 13:17:19 -06:00
Configuration is read through a toml file.
2024-05-25 00:21:36 -05:00
The config file path is specified using the `-c`/`--config` command line switch.
2023-12-08 13:17:19 -06:00
Here is an example config file:
```toml
[engine]
# The base URL that the HTTP server will be accessible on.
# This is used for formatting upload URLs.
# Setting it to "https://picture.wtf" would result in
# upload urls of "https://picture.wtf/p/abcdef.png", etc.
base_url = "http://127.0.0.1:8000"
# OPTIONAL - If set, the static key specified will be required to upload new files.
# If it is not set, no key will be required.
upload_key = "hiiiiiiii"
# OPTIONAL - specifies what to show when the site is visited on http
# It is sent with text/plain content type.
# There are two variables you can use:
# %uplcount% - total number of uploads present on the server
# %version% - current breeze version (e.g. 0.1.5)
motd = "my image host, currently hosting %uplcount% files"
2024-05-25 00:21:36 -05:00
# The maximum lifetime a temporary upload may be given, in seconds.
# It's okay to leave this somewhat high because large temporary uploads
# will just be bumped out of the cache when a new upload needs to be
# cached anyways.
max_temp_lifetime = 43200
2024-09-08 17:36:44 -05:00
# OPTIONAL - the maximum length (in bytes) a file being uploaded may be.
# A word of warning about this: the error shown to ShareX users who
# hit the limit is *not* very clear. ("connection closed" or similar)
max_upload_len = 2_147_483_648
2024-05-27 15:05:31 -05:00
# The maximum length (in bytes) an image file may be before the server
# will skip removing its EXIF data.
# The performance impact of breeze's EXIF data removal is not
# very high in everyday usage, so something like 16MiB is reasonable.
max_strip_len = 16_777_216
2024-05-25 00:21:36 -05:00
[engine.disk]
# The location that uploads will be saved to.
# It should be a path to a directory on disk that you can write to.
save_path = "/data"
2023-12-08 13:17:19 -06:00
[engine.cache]
# The file size (in bytes) that a file must be under
# to get cached.
max_length = 134_217_728
# How long a cached upload will remain cached. (in seconds)
upload_lifetime = 1800
# How often the cache will be checked for expired uploads.
# It is not a continuous scan, and only is triggered upon a cache operation.
scan_freq = 60
# How much memory (in bytes) the cache is allowed to consume.
2024-09-08 17:36:44 -05:00
mem_capacity = 4_294_967_296
2023-12-08 13:17:19 -06:00
[http]
# The address that the HTTP server will listen on. (ip:port)
# Use 0.0.0.0 as the IP to listen publicly, 127.0.0.1 only lets your
# computer access it
listen_on = "127.0.0.1:8000"
[logger]
# OPTIONAL - the current log level.
# Default level is warn.
level = "warn"
2023-02-01 19:25:38 -06:00
```
### Uploading
2024-05-25 00:21:36 -05:00
The HTTP API is pretty simple, and it's easy to make a ShareX configuration for it.
2023-02-01 19:25:38 -06:00
Uploads should be sent to `/new?name={original filename}` as a POST request. If the server uses upload keys, it should be sent to `/new?name={original filename}&key={upload key}`. The uploaded file's content should be sent as raw binary in the request body.
2024-05-25 00:21:36 -05:00
Additionally, you may specify `&lastfor={time in seconds}` to make your upload temporary, or `&keepexif=true` to tell the server not to clear EXIF data on image uploads. (if you don't know what EXIF data is, just leave it as default. you'll know if you need it)
2023-02-01 19:25:38 -06:00
Here's an example ShareX configuration for it (with a key):
```json
{
"Version": "14.1.0",
"Name": "breeze example",
"DestinationType": "ImageUploader, TextUploader, FileUploader",
"RequestMethod": "POST",
"RequestURL": "http://127.0.0.1:8000/new",
"Parameters": {
"name": "{filename}",
"key": "hiiiiiiii"
},
"Body": "Binary"
}
```