Documentation for MyCloudNest Server
Overview
MyCloudNest Server is a file management server built using the Fiber framework in Go. It provides features like file upload, download, temporary link generation, and file statistics with robust security and performance configurations.
Features
-
File Management:
- Upload, retrieve, and delete files.
- Organize files into specific directories based on file type.
-
Temporary Links:
- Generate temporary download links for files with expiration.
-
Statistics:
- Track file downloads and last access timestamps.
-
Rate Limiting:
- Control the number of requests using Redis as a storage backend.
-
Caching:
- Cache frequently accessed data with support for memory-based storage.
-
Access Control:
- Restrict access to specific IP addresses using a whitelist middleware.
Configuration
The server's configuration is loaded from ~/.cloudnest/config.toml. Below are the configurable sections:
Server Configuration
[server]
host = "0.0.0.0"
port = 3000
Rate Limiting
[rate_limit]
enabled = true
limit_body = 104857600 # 100MB
max_requests = 100
expire_time = 60
Whitelist
[whitelist]
enabled = true
whitelisted_ips = ["127.0.0.1"]
[perfomance]
perfork = false
concurrency = 65536
Cache
[cache]
enabled = true
API Endpoints
1. File Upload
- Endpoint:
/api/v1/files
- Method:
POST
- Description: Uploads a file to the server and organizes it based on its type.
2. Retrieve Files
- Endpoint:
/api/v1/files
- Method:
GET
- Description: Retrieves a list of all files with their metadata.
3. Get File
- Endpoint:
/api/v1/files/:id
- Method:
GET
- Description: Downloads or displays a file.
4. Delete File
- Endpoint:
/api/v1/files/:id
- Method:
DELETE
- Description: Deletes a file from the server and its metadata.
5. Generate Temporary Link
- Endpoint:
/api/v1/files/:id/temp-link
- Method:
POST
- Description: Generates a temporary download link for a file.
6. Validate Temporary Link
- Endpoint:
/api/v1/files/download
- Method:
GET
- Description: Validates and serves a file through a temporary link.
7. File Statistics
- Endpoint:
/api/v1/files/:id/stats
- Method:
GET
- Description: Retrieves download statistics for a specific file.
Middleware
Whitelist Middleware
- Restricts access to the application based on IP addresses.
Database
The server uses SQLite for persistent storage. The database is located at ~/.cloudnest/db.sqlite.
Tables
files: Stores metadata about files.
temporary_links: Stores information about temporary links.
file_stats: Tracks file download statistics.
How to Run
- Ensure the configuration file exists at
~/.cloudnest/config.toml.
- Start the server:
go run main.go
- Access the API at
http://<host>:<port>.
Contributors
License
This project is licensed under the MIT License.