# datatrash

A file and text uploading service with configurable time limit

![Application screenshot](./screenshot.png)

## compiling

```sh
cargo build --release
```

or

```sh
docker build -t datatrash .
docker cp datatrash:/home/rust/.cargo/bin/datatrash datatrash
```

or, to just run it in docker

```sh
docker-compose up -d --build
```

## running & config

- The static files directory needs to be next to the binary.
- The maximum filename length is 255

### General configuration

| environment variable | default value  |
| -------------------- | -------------- |
| FILES_DIR            | ./files        |
| UPLOAD_MAX_BYTES     | 8388608 (8MiB) |
| BIND_ADDRESS         | 0.0.0.0:8000   |

### Database configuration

| environment variable | default value |
| -------------------- | ------------- |
| DATABASE_URL         |               |
| DATABASE_USER        |               |
| DATABASE_PASS        |               |
| DATABASE_HOST        | localhost     |
| DATABASE_NAME        | datatrash     |

### No auth limits configuration

Require authentication for certain uploads

- The password is provided as plain text
- Uploads with longer validity than NO_AUTH_MAX_TIME require authentication
- Uploads larger than NO_AUTH_LARGE_FILE_SIZE require auth when they are valid for longer than
  NO_AUTH_LARGE_FILE_MAX_TIME
- All times are in seconds, the size is in bytes

| environment variable        | default value |
| --------------------------- | ------------- |
| AUTH_PASSWORD               |               |
| NO_AUTH_MAX_TIME            |               |
| NO_AUTH_LARGE_FILE_MAX_TIME |               |
| NO_AUTH_LARGE_FILE_SIZE     |               |