# heygem-file-util **Repository Path**: vual/heygem-file-util ## Basic Information - **Project Name**: heygem-file-util - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-29 - **Last Updated**: 2025-08-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # HeyGem File Util 一个基于Flask的文件上传下载服务,支持Docker部署。 ## 功能特性 - 文件上传:接收文件和目标路径,保存文件到指定位置 - 文件下载:根据文件路径下载文件 - 文件内容获取:以JSON格式返回文件内容 - 健康检查:服务状态检查 ## API接口 ### 1. 文件上传 **接口**: `POST /upload` **参数**: - `file`: 要上传的文件(form-data) - `target_path`: 目标保存路径(form-data) **示例**: ```bash curl -X POST -F "file=@example.txt" -F "target_path=documents/" http://localhost:5000/upload ``` ### 2. 文件下载 **接口**: `GET /download` **参数**: - `file_path`: 文件路径(query参数) **示例**: ```bash curl "http://localhost:5000/download?file_path=documents/example.txt" -O ``` ### 3. 获取文件内容 **接口**: `GET /file-content` **参数**: - `file_path`: 文件路径(query参数) **示例**: ```bash curl "http://localhost:5000/file-content?file_path=documents/example.txt" ``` ### 4. 检查文件是否存在 **接口**: `GET /check-file` **参数**: - `file_path`: 文件路径(query参数) **示例**: ```bash curl "http://localhost:5000/check-file?file_path=documents/example.txt" ``` **返回示例**: ```json { "exists": true, "file_path": "documents/example.txt", "full_path": "/app/uploads/documents/example.txt", "is_file": true } ``` ### 5. 健康检查 **接口**: `GET /health` **示例**: ```bash curl http://localhost:5000/health ``` ## Docker部署 ### 方法1: 使用docker-compose(推荐) ```bash # 构建并启动服务 docker-compose up -d # 查看日志 docker-compose logs -f # 停止服务 docker-compose down ``` ### 方法2: 使用Docker命令 ```bash # 构建镜像 docker build -t heygem-file-util . # 运行容器 docker run -d -p 5000:5000 -v $(pwd)/uploads:/app/uploads --name heygem-file-util heygem-file-util ``` ## 本地开发 ```bash # 安装依赖 pip install -r requirements.txt # 运行应用 python app.py ``` 服务将在 http://localhost:5000 启动。 ## 注意事项 - 最大文件上传大小限制为100MB - 上传的文件会保存在容器内的 `/app/uploads` 目录 - 使用docker-compose时,文件会持久化到宿主机的 `./uploads` 目录 - 文件路径参数支持相对路径,会自动添加到uploads目录下