https://github.com/geocine/file-server
https://github.com/geocine/file-server
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/geocine/file-server
- Owner: geocine
- License: mit
- Created: 2024-10-11T11:12:05.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-02-24T18:01:14.000Z (8 months ago)
- Last Synced: 2025-03-23T12:30:41.399Z (7 months ago)
- Language: Go
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Simple File Server (go-sfs)
A simple file server implemented in Go with authentication, rate limiting, and daemon mode support.
## Features
- Authentication using basic auth (username/password)
- Rate limiting to prevent abuse
- Daemon mode support
- HTTPS with self-signed certificates
- Secure file upload and download## Configuration
Default configuration (./config/config.json):
```json
{
"rateLimit": {
"requestsPerSecond": 1,
"burst": 5
},
"daemon": {
"pidFile": "./config/pid",
"logFile": "./config/log"
},
"port": 8080,
"userFile": "./config/users.json",
"storage": "./data",
"certFolder": "./config/certs"
}
```## Docker Usage
### Docker Compose Example
```yaml
version: '3'services:
go-sfs:
image: mietzen/go-sfs
container_name: go-sfs
ports:
- "8080:8080"
volumes:
- ./config:/config
- ./data:/data
environment:
- LIMITER_REQUESTS_PER_SECOND=1
- LIMITER_BURST=5
- PORT=8080
```Run with:
```bash
docker-compose up -d
```### Adding a User (Docker)
```bash
docker exec go-sfs /go-sfs -u username
```## Binary Usage
### Build
```bash
git clone https://github.com/mietzen/go-sfs.git
cd go-sfs
go build
go test
```### Running the Server
```bash
./go-sfs
```### Environment Variables
- USER_FILE=/config/users.json
- STORAGE=/data
- CERTS=/config/certs
- LIMITER_REQUESTS_PER_SECOND=1
- LIMITER_BURST=5
- PORT=8080### Adding a User
```bash
./go-sfs -u username -p password
```### Daemon Mode
```bash
./go-sfs -d
```## API Endpoints
- Upload File: `PUT /upload/{path}`
- Download File: `GET /download/{path}`
- List Files: `GET /files`
- Delete File: `DELETE /delete/{path}`### Examples
#### Upload
```bash
curl -u username:password -X PUT -T "local/file" http://localhost:8080/upload/remote/file
```#### Download
```bash
curl -u username:password -OJ http://localhost:8080/download/path/to/file
```#### List Files
```bash
curl -u username:password http://localhost:8080/files
```#### Delete
```bash
curl -u username:password -X DELETE http://localhost:8080/delete/path/to/file
```## License
MIT License - see the [LICENSE](./LICENSE) file for details.