# file-server **Repository Path**: jack_of_disco/file-server ## Basic Information - **Project Name**: file-server - **Description**: 一个高效、可靠的文件服务系统,支持多种文件操作和管理功能,适用于各类开发和生产环境。 使用Go语言搭建一个高效的文件上传下载服务器,占用内存低,直接编译成二进制文件,部署到Linux上无须下载额外的Go语言编译器 - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-19 - **Last Updated**: 2025-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # file-server # # # Introduction An efficient and reliable file service system supports a variety of file operation and management functions, and is suitable for various development and production environments. Build an efficient file upload and download server using Go language, which takes up low memory and can be directly compiled into binary files. When deployed on Linux, there is no need to download an additional Go language compiler. --- ## 1. Upload file interface # # # Basic information - **URL**: `/upload` -* * Method * **: `POST. -* * Description * *: Upload a file to the server (size limit is 500MB) # # # Request parameters | Parameter Location | Parameter Name | Type | Required | Description | | ---------------- | ------ | ---- | ---- | ------------------------------------------- | | Body (form-data) | `file` | file | is a file to be uploaded, using multipart/form-data format | # # # Response format * * Success (200 OK)** ```json { "message": "File uploaded successfully.", "filePath": "example.txt" } ``` * * Failed (4xx/5xx)** ```json { "error": "error description information" } ``` # # # Abnormal situation | HTTP status code | error message | reason | | ----------- | ---------------------------------------- | ---------------------------- | | 500 | `Service is not available.` | The service cannot be used (communication is not allowed) | | 413 |` The file size exceeds the 500MB limit. `| The file size exceeds the 500mb limit | | 500 | `File save failed` | Save failed | | 400 | `File acquisition failed` | Error in uploading parameters | # # # Sample request ```bash curl -X POST http://your-server/upload \ -F "file=@/path/to/your/file.txt" ``` --- ## 2. Download file interface # # # Basic information - **URL**: `/download/type/:filename` -* * Method * **: `GET. -* * Description * *: Download the specified file and return to the binary stream. # # # Request parameters | Parameter Location | Parameter Name | Type | Required | Description | | -------- | ---------- | ------ | ---- | ------------------------------------------------------ | | Path | `filename` | string | is a | file identifier, which supports the special values ` softPackage' and ` r- ` prefix |. | Query | `df` | string | Condition | When filename starts with ` r- `, * * must be provided to specify the actual filename | # # # Response format * * Success (200 OK)** -Response body: file binary stream -Response header: - `Content-Disposition: attachment; Filename= "actual filename" ` - `Content-Type: application/octet-stream` * * Failure (4xx)** ```json { "error": "error description information" } ``` # # # Abnormal situation | HTTP status code | error message | reason | | ----------- | --------------------------- | ---------------------------- | | 500 | `Service is not available.` | The service cannot be used (communication is not allowed) | | 404 | `File does not exist` | File does not exist | # # # Sample request * * ordinary file download * * ```bash curl -X GET http://your-server/download/type/document.pdf ``` **softPackage special type * * ```bash curl -X GET http://your-server/download/type/softPackage ``` * * r- type file with parameters * * ```bash curl -X GET "http://your-server/download/type/r-12345? df=config.json" ``` --- ## 3. Error code quick lookup table | Error message | Meaning | Solution | | ---------------------------------------- | -------------------- | -------------------------- | | `Service is not available.` | The internal service of the server is not ready | Contact the administrator to check the service status | |` The file size exceeds the 500mb limit .`| The file is too large | Do not upload large files or upload them separately | | `File acquisition failed` | Error in uploading parameters | Make sure to upload with ` file' field name | | `File save failed` | Save failed | Check disk space and permissions | | `File does not exist` | The file does not exist | Confirm the file name or contact the administrator | --- # # Precautions 1. ** File size limit * *: 500MB maximum. 2. ** Special file types * *: -`softPackage' will skip some service checks. The-`r- `prefix requires an additional `df` parameter. 3. ** Encoding * *: All responses are UTF-8 encoded.