jaf -> yaf

This commit is contained in:
lyx0 2023-09-04 20:49:33 +02:00
parent 0646161736
commit 1787fca81a
5 changed files with 12 additions and 15 deletions

View file

@ -1,5 +1,5 @@
# jaf - Just Another Fileshare
jaf is a simple Go program to handle file uploads.
# yaf - Yet Another (Temporary) Fileshare
yaf is a simple Go program to handle file uploads.
If you also want to serve the uploaded files, consider a web server like [nginx](https://nginx.org/en/).
## Installation with docker-compose and local build
@ -30,7 +30,7 @@ If you plan on using a systemd service or another init system, you might want to
## Configuration
### yaf
There are just a few parameters that need to be configured for jaf.
There are just a few parameters that need to be configured for yaf.
Refer to the `example.conf` file:
```
Port: 4711
@ -48,9 +48,9 @@ FileExpiration: false
Option | Use
------------------ | -------------------------------------------------------------------
`Port` | the port number jaf will listen on
`LinkPrefix` | a string that will be prepended to the file name generated by jaf
`FileDir` | path to the directory jaf will save uploaded files in. if using docker-compose needs to be the same as the target mount point (the right side)
`Port` | the port number yaf will listen on
`LinkPrefix` | a string that will be prepended to the file name generated by yaf
`FileDir` | path to the directory yaf will save uploaded files in. if using docker-compose needs to be the same as the target mount point (the right side)
`LinkLength` | the number of characters the generated file name is allowed to have
`ScrubExif` | whether to remove EXIF tags from uploaded JPEG and PNG images (`true` or `false`)
`ExifAllowedIds` | a space-separated list of EXIF tag IDs that should be preserved through EXIF scrubbing (only relevant if `ScrubExif` is `true`)
@ -61,7 +61,7 @@ Option | Use
Make sure the user running yaf has suitable permissions to read, and write to, `FileDir`.
Also note that `LinkLength` directly relates to the number of files that can be saved.
Since jaf only uses alphanumeric characters for file name generation, a maximum of `(26 + 26 + 10)^LinkLength` names can be generated.
Since yaf only uses alphanumeric characters for file name generation, a maximum of `(26 + 26 + 10)^LinkLength` names can be generated.
#### A Note on EXIF Scrubbing
EXIF scrubbing can be enabled via the `ScrubExif` config key.
@ -86,7 +86,7 @@ The path format is as follows:
2. Tags in the thumbnail section follow the same format but paths start with `IFD1/` instead of `IFD`.
### nginx
If you use a reverse-proxy to forward requests to jaf, make sure to correctly forward the original request headers.
If you use a reverse-proxy to forward requests to yaf, make sure to correctly forward the original request headers.
For nginx, this is achieved via the `proxy_pass_request_headers on;` option.
If you want to limit access to yaf (e.g. require basic authentication), you will also need to do this via your reverse-proxy.
@ -142,10 +142,10 @@ docker run \
```
Port 4711 is the default port for the server in `example.conf`, if you've changed this in your config you'll need to change this in the `docker run` invocations above too.
The above runs forwards the jaf port from 4711 in the container to 4711 on your local system.
The above runs forwards the yaf port from 4711 in the container to 4711 on your local system.
## Usage
You can use jaf with any application that can send POST requests (e.g. ShareX/ShareNix or just `curl`).
You can use yaf with any application that can send POST requests (e.g. ShareX/ShareNix or just `curl`).
Make sure the file you want to upload is attached as a `multipart/form-data` field named `file`.
In `curl`, a request to upload the file `/home/alice/foo.txt` could look like this:
```bash

View file

@ -41,7 +41,7 @@ func ConfigFromFile(filePath string) (*Config, error) {
retval := &Config{
Port: 4711,
LinkPrefix: "https://yaf.example.com/",
FileDir: "/var/www/jaf/",
FileDir: "/var/www/yaf/",
LinkLength: 5,
ScrubExif: true,
ExifAllowedIds: []uint16{},

1
go.mod
View file

@ -10,7 +10,6 @@ require (
github.com/gabriel-vasile/mimetype v1.4.1
github.com/go-errors/errors v1.1.1
github.com/julienschmidt/httprouter v1.3.0
github.com/leon-richardt/jaf v0.3.1
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
)

2
go.sum
View file

@ -32,8 +32,6 @@ github.com/golang/geo v0.0.0-20200319012246-673a6f80352d/go.mod h1:QZ0nwyI2jOfgR
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/leon-richardt/jaf v0.3.1 h1:af6p+xr7KX9OxwuiUHQSG8yVJQppugpW+iS+ptIQ0bM=
github.com/leon-richardt/jaf v0.3.1/go.mod h1:rvBGLF1s8u3XNUTEqGeOSYVoEnIIwI/pKeTEdMdKtJk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=

2
yaf.go
View file

@ -61,7 +61,7 @@ func main() {
}
router := httprouter.New()
log.Printf("starting jaf on port %d\n", config.Port)
log.Printf("starting yaf on port %d\n", config.Port)
router.HandlerFunc(http.MethodPost, "/upload", handler.PostUpload)
router.HandlerFunc(http.MethodPost, "/uploadweb", handler.PostUploadRedirect)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", config.Port), router))