https://github.com/infinimesh/http-fs
HTTP File Server written in Go
https://github.com/infinimesh/http-fs
docker file-upload go golang http infinimesh
Last synced: about 1 year ago
JSON representation
HTTP File Server written in Go
- Host: GitHub
- URL: https://github.com/infinimesh/http-fs
- Owner: infinimesh
- License: apache-2.0
- Created: 2022-05-17T15:11:13.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-07T02:34:36.000Z (about 3 years ago)
- Last Synced: 2025-01-10T04:12:04.397Z (about 1 year ago)
- Topics: docker, file-upload, go, golang, http, infinimesh
- Language: Go
- Homepage:
- Size: 117 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# infinimesh HTTP FileServer
[](https://github.com/infinimesh/http-fs/actions/workflows/ci.yml)
Simple HTTP FileServer made for infimesh, but can be extended and applied for other services with simillar purposes.
Right now only FileSystem storage is supported.
## General logic
Server understands two things:
- namespaces (folders)
- files (well, just files)
So these are routes:
GET /{ns} - returns stats (files and their props) in the requested namespace
DELETE /{ns} - deletes namespace(and its files)
GET /{ns}/{file} - returns file itself
POST /{ns}/{file} - uploads file
DELETE /{ns}/{file} - deletes file
See the [Postman Collection](https://github.com/infinimesh/http-fs/blob/master/misc/http-fs.json) to try it yourself.
## Installation
Docker(compose) service example:
```yaml
http-fs:
image: ghcr.io/infinimesh/http-fs:latest
restart: always
ports:
- "80:8000"
environment:
ADDR: :8000
REPO: repo:8000
STATIC_DIR: /static # you should probably map this to some real volume
UPLOAD_LIMIT: 10485760 # 10MB
LOG_LEVEL: -1 # -1 for debug, 0 for info, 1 for warning, 2 for error (defaults to info)
```
## Default logic
Namespaces are mapped to:
1. infinimesh namespaces - middleware determines access to the folder basing on the user's permissions
2. filesystem directory
These is the result of using [InfinimeshMiddleware](https://github.com/infinimesh/http-fs/blob/master/pkg/mw/infinimesh.go) and [FileSystem](https://github.com/infinimesh/http-fs/blob/2052af2e6f9ffa67bcb0c2cdbf1ac9f54e550bfd/pkg/io/fs/fs.go) [IOHandler](https://github.com/infinimesh/http-fs/blob/master/pkg/io/fs/fs.go#L17)
## How to extend
### Middleware
Middleware is a `mux` middleware which adds `Access` to context.
Access defined [here](https://github.com/infinimesh/http-fs/blob/2052af2e6f9ffa67bcb0c2cdbf1ac9f54e550bfd/pkg/mw/mw.go). It's a simple structure which defined if requestor has Read and Write access to the namespace/file.
You can also see the [SampleMiddleware](https://github.com/infinimesh/http-fs/blob/master/pkg/mw/sample.go) to (maybe) get a better idea.
### IOHandler
IOHandler is an interface which has few methods decribed [here](https://github.com/infinimesh/http-fs/blob/master/pkg/io/io.go#L18)
### Building
Replace used middlewares and IOHandler with your own and compile.