Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zikwall/go-fileserver
Simple, Powerful and Productive file server written in Go with authentication support (JWT, token, HTTP Basic)
https://github.com/zikwall/go-fileserver
file-upload fileserver go golang server storage webdav
Last synced: 4 days ago
JSON representation
Simple, Powerful and Productive file server written in Go with authentication support (JWT, token, HTTP Basic)
- Host: GitHub
- URL: https://github.com/zikwall/go-fileserver
- Owner: zikwall
- Created: 2021-02-02T15:23:38.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-29T17:09:51.000Z (over 3 years ago)
- Last Synced: 2024-06-21T02:15:42.161Z (5 months ago)
- Topics: file-upload, fileserver, go, golang, server, storage, webdav
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![build](https://github.com/zikwall/go-fileserver/workflows/tests/badge.svg)](https://github.com/zikwall/go-fileserver/actions)
Go-fileserver
Simple, Powerful and Productive file server written in Go
### Options
| Name | Env |
| :---------------------------------: | :---------------------: |
| `bind-address` (`0.0.0.0:1337`) | `BIND_ADDRESS` |
| `token` | `TOKEN` |
| `root-file-directory` (`./tmp`) | `ROOT_FILE_DIRECTORY` |
| `enable-secure` (`false`) | `ENABLE_SECURE` |
| `secure-type` (`0`) | `SECURE_TYPE` |
| `users` (`./tmp`) | `USERS` |### Authorization types
- [x] Simple token auth (default)
```shell
--secure-type 0
--enable-secure
--token='token_here'
```- __token__: With this parameter, you can protect yourself from unauthorized access, it can be empty, if empty-it is generated automatically
From | Usage
--- | --- |
Request header | `Authorization: Bearer `
Query param | `?token=`
Form value | `token=`- [x] HTTP Basic auth
```shell
--secure-type 1
--enable-secure
--users='qwx:1337'
--users='qwx2:13372'
--users='qwx3:13373'
```- [ ] JWT based auth
```shell
// todo
```### How to use?
#### with single file (basic requests)
```shell
$ curl -i -X POST \
-H "Content-Type: multipart/form-data" \
-F "[email protected]" \
http://localhost:1337?token=123456
``````shell
$ curl -i -X POST \
-H "Content-Type: multipart/form-data" \
-F "[email protected]" \
http://qwx:1337@localhost:1337
``````shell
// todo
```#### with multiple files
```shell
$ curl -i -X POST \
-H "Content-Type: multipart/form-data" \
-F "files[][email protected]" \
-F "files[][email protected]" \
http://localhost:1337?token=123456
```#### with data binary format
```shell
$ curl -i -X POST \
--data-binary @.gitignore \
http://localhost:1337/.gitignore?token=123456
```
> The name from the request URI will be taken into account as the file name### How to view files
To view the files just click on the link with the domain, and the file name at the end:
**Simple**
> http://localhost:1337/.gitignore?token=123456**HTTP Basic**
> http://qwx:1337@localhost:1337/.gitignore### How to run?
- `$ git clone https://github.com/zikwall/go-fileserver`
- `$ go run . --bind-address localhost:1337 --token 123456 --enable-secure`#### with Docker
```shell
$ docker run -d -p 1338:1338 \
-e BIND_ADDRESS='0.0.0.0:1338' \
-e SECURE_TYPE=1 \
-e USERS='username:password' \
-e ENABLE_SECURE='true' \
-e ENABLE_TSL='true' \
-e TSL_CERT_FILE='/mnt/ssl.cert' \
-e TSL_KEY_FILE='/mnt/ssl.key' \
-v $HOME/tmp:/app/tmp \
-v $PWD:/mnt \
--name go-fileserver-example qwx1337/go-fileserver:latest
```### Tests
- `$ go test -v ./...`