mirror of
https://github.com/lyx0/yaf.git
synced 2024-11-13 19:49:53 +01:00
jaf -> yaf
This commit is contained in:
parent
0646161736
commit
1787fca81a
5 changed files with 12 additions and 15 deletions
20
README.md
20
README.md
|
@ -1,5 +1,5 @@
|
||||||
# jaf - Just Another Fileshare
|
# yaf - Yet Another (Temporary) Fileshare
|
||||||
jaf is a simple Go program to handle file uploads.
|
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/).
|
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
|
## 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
|
## Configuration
|
||||||
### yaf
|
### 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:
|
Refer to the `example.conf` file:
|
||||||
```
|
```
|
||||||
Port: 4711
|
Port: 4711
|
||||||
|
@ -48,9 +48,9 @@ FileExpiration: false
|
||||||
|
|
||||||
Option | Use
|
Option | Use
|
||||||
------------------ | -------------------------------------------------------------------
|
------------------ | -------------------------------------------------------------------
|
||||||
`Port` | the port number jaf will listen on
|
`Port` | the port number yaf will listen on
|
||||||
`LinkPrefix` | a string that will be prepended to the file name generated by jaf
|
`LinkPrefix` | a string that will be prepended to the file name generated by yaf
|
||||||
`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)
|
`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
|
`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`)
|
`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`)
|
`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`.
|
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.
|
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
|
#### A Note on EXIF Scrubbing
|
||||||
EXIF scrubbing can be enabled via the `ScrubExif` config key.
|
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`.
|
2. Tags in the thumbnail section follow the same format but paths start with `IFD1/` instead of `IFD`.
|
||||||
|
|
||||||
### nginx
|
### 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.
|
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.
|
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.
|
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
|
## 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`.
|
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:
|
In `curl`, a request to upload the file `/home/alice/foo.txt` could look like this:
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -41,7 +41,7 @@ func ConfigFromFile(filePath string) (*Config, error) {
|
||||||
retval := &Config{
|
retval := &Config{
|
||||||
Port: 4711,
|
Port: 4711,
|
||||||
LinkPrefix: "https://yaf.example.com/",
|
LinkPrefix: "https://yaf.example.com/",
|
||||||
FileDir: "/var/www/jaf/",
|
FileDir: "/var/www/yaf/",
|
||||||
LinkLength: 5,
|
LinkLength: 5,
|
||||||
ScrubExif: true,
|
ScrubExif: true,
|
||||||
ExifAllowedIds: []uint16{},
|
ExifAllowedIds: []uint16{},
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -10,7 +10,6 @@ require (
|
||||||
github.com/gabriel-vasile/mimetype v1.4.1
|
github.com/gabriel-vasile/mimetype v1.4.1
|
||||||
github.com/go-errors/errors v1.1.1
|
github.com/go-errors/errors v1.1.1
|
||||||
github.com/julienschmidt/httprouter v1.3.0
|
github.com/julienschmidt/httprouter v1.3.0
|
||||||
github.com/leon-richardt/jaf v0.3.1
|
|
||||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
|
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -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/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 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
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-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
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=
|
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
|
||||||
|
|
2
yaf.go
2
yaf.go
|
@ -61,7 +61,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
router := httprouter.New()
|
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, "/upload", handler.PostUpload)
|
||||||
router.HandlerFunc(http.MethodPost, "/uploadweb", handler.PostUploadRedirect)
|
router.HandlerFunc(http.MethodPost, "/uploadweb", handler.PostUploadRedirect)
|
||||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", config.Port), router))
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", config.Port), router))
|
||||||
|
|
Loading…
Reference in a new issue