### Install Frontend Dependencies and Run Source: https://github.com/vastsa/filecodebox/blob/master/readme.md Navigate to the frontend directory, install Node.js dependencies, and start the development server. ```bash # 前端仓库: https://github.com/vastsa/FileCodeBoxFronted cd fcb-fronted npm install npm run dev ``` -------------------------------- ### Install Frontend Dependencies and Start Dev Server Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/introduction.md Navigate to the frontend directory, install Node.js dependencies, and start the development server for the Vue.js frontend. ```bash cd fcb-fronted npm install npm run dev ``` -------------------------------- ### Manual Deployment of FileCodeBox Source: https://github.com/vastsa/filecodebox/blob/master/readme_en.md Manually deploy FileCodeBox by cloning the repository, installing dependencies, and starting the service. ```bash # 1. Clone the repository git clone https://github.com/vastsa/FileCodeBox.git cd FileCodeBox # 2. Install dependencies pip install -r requirements.txt # 3. Start the service python main.py ``` -------------------------------- ### Install Backend Dependencies and Run Source: https://github.com/vastsa/filecodebox/blob/master/readme.md Install Python dependencies using pip and run the main application file. ```bash pip install -r requirements.txt python main.py ``` -------------------------------- ### Expiration Settings Examples Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/share.md Examples demonstrating how to set different expiration policies for shared content using `expire_value` and `expire_style`. ```bash # 文件 3 天后过期 expire_value=3, expire_style=day # 文件 12 小时后过期 expire_value=12, expire_style=hour # 文件 30 分钟后过期 expire_value=30, expire_style=minute # 文件永不过期 expire_value=1, expire_style=forever # 文件被下载 5 次后过期 expire_value=5, expire_style=count ``` -------------------------------- ### Upload Configuration Example Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/upload.md Example Python code demonstrating how to configure upload settings, including maximum file size, chunked upload, rate limiting, and expiration methods. ```python # Allow 100MB file uploads, enable chunked upload uploadSize = 104857600 enableChunk = 1 # Relax upload rate limit: max 50 uploads per 5 minutes uploadMinute = 5 uploadCount = 50 # Only allow expiration by days and count expireStyle = ["day", "count"] ``` -------------------------------- ### File Upload Configuration Example Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/upload.md Example Python code demonstrating how to configure upload settings such as maximum file size, chunked uploads, frequency limits, and expiration styles. ```python # 允许上传 100MB 文件,启用分片上传 uploadSize = 104857600 enableChunk = 1 # 放宽上传频率限制:每 5 分钟最多 50 次 uploadMinute = 5 uploadCount = 50 # 只允许按天和按次数过期 expireStyle = ["day", "count"] ``` -------------------------------- ### Initialize Upload Response Example Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/upload.md Example response upon successful initialization of a chunked upload. It provides the upload ID and details about existing uploaded chunks. ```json { "code": 200, "detail": { "existed": false, "upload_id": "abc123def456789", "chunk_size": 5242880, "total_chunks": 20, "uploaded_chunks": [] } } ``` -------------------------------- ### Get File Info Response Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Example JSON response when retrieving file information by its share code. ```json { "code": 200, "msg": "success", "detail": { "code": "abc123", "name": "example.txt", "size": 1024, "text": "文件内容或下载链接" } } ``` -------------------------------- ### Install OneDrive Dependencies Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/storage.md Install the required Python libraries for interacting with OneDrive and Microsoft Graph API. ```bash pip install msal Office365-REST-Python-Client ``` -------------------------------- ### Install OpenDAL Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/storage.md Install the OpenDAL Python package using pip. ```bash pip install opendal ``` -------------------------------- ### Get Configuration Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/management.md Retrieves the current system configuration settings. ```APIDOC ## GET /admin/config/get ### Description Fetches the current configuration parameters of the system. ### Method GET ### Endpoint /admin/config/get ### Parameters #### Header Parameters - **Authorization** (string) - Required - Bearer token for authentication. ``` -------------------------------- ### Configuration - Get Configuration Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/management.md Retrieves all current system configuration settings. ```APIDOC ## GET /admin/config/get ### Description Retrieves all current system configuration settings. ### Method GET ### Endpoint /admin/config/get ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. ``` -------------------------------- ### Get File Info by Code Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md cURL example to retrieve file information using its share code. The '-L' flag follows redirects for direct download. ```bash # 通过取件码下载文件 curl -L "http://localhost:12345/share/select/?code=abc123" -o downloaded_file ``` -------------------------------- ### Get Config Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/api/index.md Retrieves the current system configuration settings. ```APIDOC ## GET /admin/config/get ### Description Get system configuration. ### Method GET ### Endpoint /admin/config/get ``` -------------------------------- ### Start Docker Compose Services Source: https://github.com/vastsa/filecodebox/blob/master/readme.md Starts the services defined in the Docker Compose file in detached mode. ```bash docker compose up -d ``` -------------------------------- ### Upload Chunk cURL Example Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/upload.md Example using cURL to upload a specific chunk of a file. Replace placeholders with actual upload ID, chunk index, and file path. ```bash # Upload first chunk (index 0) curl -X POST "http://localhost:12345/chunk/upload/chunk/abc123def456789/0" \ -F "chunk=@/path/to/chunk_0" ``` -------------------------------- ### 通过取件码下载文件 Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/upload.md 使用 GET 请求 `/share/select/` 接口,并提供文件的取件码作为 `code` 参数,以下载文件。使用 `-L` 选项跟随重定向。 ```bash # 通过取件码下载文件 curl -L "http://localhost:12345/share/select/?code=取件码" -o downloaded_file ``` -------------------------------- ### Get Admin Authentication Token Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/api/index.md Obtain an authentication token by sending a POST request to the login endpoint. Requires the admin password set during setup. ```bash curl -X POST "http://localhost:12345/admin/login" \ -H "Content-Type: application/json" \ -d '{"password": ""}' ``` -------------------------------- ### Get Config Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Retrieve the current system configuration information. ```APIDOC ## GET /admin/config/get ### Description Get system configuration information. ### Method GET ### Endpoint /admin/config/get ``` -------------------------------- ### API Response Example Source: https://github.com/vastsa/filecodebox/blob/master/readme_en.md This is an example of a successful API response when sharing a file. It includes a status code, a success message, and details about the shared item. ```json { "code": 200, "msg": "success", "detail": { "code": "abcd1234", "name": "file.txt" } } ``` -------------------------------- ### Nutstore WebDAV Configuration Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/storage.md Configuration example for Nutstore. Nutstore requires an app password, which can be generated through its web interface under Account Info -> Security Options. ```bash file_storage=webdav webdav_url=https://dav.jianguoyun.com/dav/ webdav_username=your_email@example.com webdav_password=your_app_password webdav_root_path=FileCodeBox ``` -------------------------------- ### FileCodeBox Configuration File (.env) Source: https://github.com/vastsa/filecodebox/wiki/部署教程 Example .env file for configuring FileCodeBox versions 1.7 and below. Place this file in /opt/FileCodeBox/ to apply settings. It includes options for port, database, uploads, and storage. ```dotenv # 端口 PORT=12345 # Sqlite数据库文件 DATABASE_URL=sqlite+aiosqlite:///database.db # 静态文件夹 DATA_ROOT=./static # 静态文件夹URL STATIC_URL=/static # 开启上传 ENABLE_UPLOAD=True # 错误次数 ERROR_COUNT=5 # 错误限制分钟数 ERROR_MINUTE=10 # 上传次数 UPLOAD_COUNT=60 # 上传限制分钟数 UPLOAD_MINUTE=1 # 删除过期文件的间隔(分钟) DELETE_EXPIRE_FILES_INTERVAL=10 # 管理地址 ADMIN_ADDRESS=admin # 管理密码 ADMIN_PASSWORD=admin # 文件大小限制,默认10MB FILE_SIZE_LIMIT=10 # 网站标题 TITLE=文件快递柜 # 网站描述 DESCRIPTION=FileCodeBox,文件快递柜,口令传送箱,匿名口令分享文本,文件,图片,视频,音频,压缩包等文件 # 网站关键词 KEYWORDS=FileCodeBox,文件快递柜,口令传送箱,匿名口令分享文本,文件,图片,视频,音频,压缩包等文件 # 存储引擎 STORAGE_ENGINE=filesystem # 如果使用阿里云OSS服务需额外创建如下参数: # 阿里云账号AccessKey KeyId=阿里云账号AccessKey # 阿里云账号AccessKeySecret KeySecret=阿里云账号AccessKeySecret # 阿里云OSS Bucket的地域节点 OSS_ENDPOINT=阿里云OSS Bucket的地域节点 # 阿里云OSS Bucket的BucketName BUCKET_NAME=阿里云OSS Bucket的BucketName ``` -------------------------------- ### Resume Upload Flow Example (JavaScript) Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/upload.md JavaScript code demonstrating the flow for resuming an interrupted chunked upload. It initializes, uploads missing chunks, and completes the process. ```javascript // 1. Initialize upload const initResponse = await fetch('/chunk/upload/init/', { method: 'POST', body: JSON.stringify({ file_name: 'large_file.zip', file_size: fileSize, chunk_size: 5 * 1024 * 1024, file_hash: fileHash }) }); const { upload_id, uploaded_chunks, total_chunks } = await initResponse.json(); // 2. Upload incomplete chunks for (let i = 0; i < total_chunks; i++) { if (!uploaded_chunks.includes(i)) { const chunk = file.slice(i * chunkSize, (i + 1) * chunkSize); await fetch(`/chunk/upload/chunk/${upload_id}/${i}`, { method: 'POST', body: chunk }); } } // 3. Complete upload await fetch(`/chunk/upload/complete/${upload_id}`, { method: 'POST', body: JSON.stringify({ expire_value: 7, expire_style: 'day' }) }); ``` -------------------------------- ### Admin Login Response Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Example JSON response upon successful admin login, containing the authentication token. ```json { "code": 200, "msg": "success", "detail": { "token": "xxx.xxx.xxx", "token_type": "Bearer" } } ``` -------------------------------- ### Nextcloud WebDAV Configuration Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/storage.md Configuration example for Nextcloud. It is recommended to use an app password for security. Follow the provided steps to generate one in Nextcloud settings. ```bash file_storage=webdav webdav_url=https://your-nextcloud.com/remote.php/dav/files/username/ webdav_username=your_username webdav_password=your_app_password webdav_root_path=FileCodeBox ``` -------------------------------- ### Share File (Authenticated) Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md cURL example for uploading and sharing a file when authentication is required. Includes the Authorization header. ```bash # 需要认证时 curl -X POST "http://localhost:12345/share/file/" \ -H "Authorization: Bearer xxx.xxx.xxx" \ -F "file=@/path/to/file.txt" ``` -------------------------------- ### Admin File List API Endpoint and Response Example Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/api/index.md This endpoint retrieves a paginated list of system files. The response includes pagination details and a list of file objects. ```HTTP GET /admin/file/list?page=1&size=10&keyword="" ``` ```JSON { "code": 200, "msg": "success", "detail": { "page": 1, "size": 10, "total": 100, "data": [ { "id": 1, "name": "example.txt", "size": 1024, "created_at": "2024-01-01 12:00:00" } ] } } ``` -------------------------------- ### Get System Configuration API Endpoint Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/api/index.md This endpoint retrieves the current system configuration settings. ```HTTP GET /admin/config/get ``` -------------------------------- ### Get Configuration API Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/management.md Retrieve the current system configuration. Requires a Bearer token. ```http GET /admin/config/get Authorization: Bearer ``` -------------------------------- ### Deploy FileCodeBox with Docker Compose Source: https://github.com/vastsa/filecodebox/blob/master/readme_en.md Configure and run FileCodeBox using Docker Compose. This setup includes environment variables for worker processes and log level. ```yaml services: filecodebox: image: lanol/filecodebox:latest container_name: filecodebox restart: unless-stopped ports: - "12345:12345" volumes: - ./data:/app/data environment: - WORKERS=4 - LOG_LEVEL=info ``` ```bash docker compose up -d ``` -------------------------------- ### Query File Information API Response (File) Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/share.md Example response when querying for a file. It provides the extract code, filename, size, and a download URL. ```json { "code": 200, "detail": { "code": "123456", "name": "example.pdf", "size": 1048576, "text": "https://example.com/download/..." } } ``` -------------------------------- ### File List Response Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Example JSON response for the admin file list endpoint, including pagination details and a list of files. ```json { "code": 200, "msg": "success", "detail": { "page": 1, "size": 10, "total": 100, "data": [ { "id": 1, "name": "example.txt", "size": 1024, "created_at": "2024-01-01 12:00:00" } ] } } ``` -------------------------------- ### Share File Response Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Example JSON response after successfully sharing a file, containing the share code and filename. ```json { "code": 200, "msg": "success", "detail": { "code": "abc123", "name": "example.txt" } } ``` -------------------------------- ### Get File List Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/management.md Retrieves a paginated list of files with optional keyword filtering. ```APIDOC ## GET /admin/file/list ### Description Retrieves a list of files, supporting pagination and keyword search. ### Method GET ### Endpoint /admin/file/list ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number for pagination. Defaults to 1. - **size** (integer) - Optional - The number of items per page. Defaults to 10. - **keyword** (string) - Optional - A keyword to filter the file list. #### Header Parameters - **Authorization** (string) - Required - Bearer token for authentication. ``` -------------------------------- ### Query File Information Response (Text) Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/share.md Example JSON response when querying for text content. Includes the text content directly in the response. ```json { "code": 200, "detail": { "code": "123456", "name": "Text", "size": 1024, "text": "This is the shared text content..." } } ``` -------------------------------- ### File List Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Get a paginated list of files in the system, with options for searching by keyword. ```APIDOC ## GET /admin/file/list ### Description Get the list of files in the system. ### Method GET ### Endpoint /admin/file/list ### Parameters #### Query Parameters - **page** (integer) - Optional - Current page number. Defaults to 1. - **size** (integer) - Optional - Number of items per page. Defaults to 10. - **keyword** (string) - Optional - Search keyword. Defaults to "". ### Response #### Success Response (200) - **page** (integer) - Current page number. - **size** (integer) - Number of items per page. - **total** (integer) - Total number of files. - **data** (array) - List of files, where each file object contains: - **id** (integer) - File ID. - **name** (string) - File name. - **size** (integer) - File size in bytes. - **created_at** (string) - File creation timestamp. ``` -------------------------------- ### Get Token Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Obtain an authentication token by logging in with the administrator password. This is required when guest uploads are disabled. ```APIDOC ## POST /admin/login ### Description Administrator login to obtain a token. ### Method POST ### Endpoint /admin/login ### Parameters #### Request Body - **password** (string) - Required - Administrator password ### Request Example ```json { "password": "<初始化时设置的管理员密码>" } ``` ### Response #### Success Response (200) - **token** (string) - The authentication token. - **token_type** (string) - The type of token, typically 'Bearer'. ``` -------------------------------- ### Share Text (Guest Upload) Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md cURL example for sharing text content when guest uploads are enabled. Includes text and optional expiration parameters. ```bash # 游客上传(openUpload=1 时) curl -X POST "http://localhost:12345/share/text/" \ -F "text=这是要分享的文本内容" \ -F "expire_value=1" \ -F "expire_style=day" ``` -------------------------------- ### Share File (Default Expiration) Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md cURL example for uploading and sharing a file with default expiration (1 day). ```bash # 上传文件(默认1天有效期) curl -X POST "http://localhost:12345/share/file/" \ -F "file=@/path/to/file.txt" ``` -------------------------------- ### Share File (Count Expiration) Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md cURL example for uploading and sharing a file with an expiration based on download count (10 times). ```bash # 上传文件(可下载10次) curl -X POST "http://localhost:12345/share/file/" \ -F "file=@/path/to/file.txt" \ -F "expire_value=10" \ -F "expire_style=count" ``` -------------------------------- ### Share File (Custom Expiration) Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md cURL example for uploading and sharing a file with a custom expiration period (7 days). ```bash # 上传文件(7天有效期) curl -X POST "http://localhost:12345/share/file/" \ -F "file=@/path/to/file.txt" \ -F "expire_value=7" \ -F "expire_style=day" ``` -------------------------------- ### Dashboard Data Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Example JSON response for the admin dashboard, showing system statistics like file counts and storage usage. ```json { "code": 200, "msg": "success", "detail": { "totalFiles": 100, "storageUsed": "1.5GB", "sysUptime": "10天", "yesterdayCount": 50, "yesterdaySize": "500MB", "todayCount": 30, "todaySize": "300MB" } } ``` -------------------------------- ### View Docker Container Logs Source: https://github.com/vastsa/filecodebox/wiki/部署教程 Command to view the logs of the FileCodeBox Docker container. This is useful for retrieving initial passwords and backend addresses upon first installation. ```bash docker logs filecodebox ``` -------------------------------- ### Query File Information API Response (Text) Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/share.md Example response when querying for shared text. It includes the extract code, 'Text' as the name, size, and the text content itself. ```json { "code": 200, "detail": { "code": "123456", "name": "Text", "size": 1024, "text": "这是分享的文本内容..." } } ``` -------------------------------- ### Get File Information by Share Code Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/api/index.md Retrieve file information using its share code. This endpoint also facilitates direct file downloads. ```bash # Download file by extraction code curl -L "http://localhost:12345/share/select/?code=abc123" -o downloaded_file ``` -------------------------------- ### 认证后上传文件和分享文本 Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/upload.md 当游客上传被禁用时,需要先通过 `/admin/login` 接口获取认证 token,然后在上传文件或分享文本的请求头中携带该 token。 ```bash # 1. 登录获取 token curl -X POST "http://localhost:12345/admin/login" -H "Content-Type: application/json" -d '{"password": "<初始化时设置的管理员密码>"}' ``` ```bash # 返回: {"code":200,"msg":"success","detail":{"token":"xxx.xxx.xxx","token_type":"Bearer"}} ``` ```bash # 2. 使用 token 上传文件 curl -X POST "http://localhost:12345/share/file/" -H "Authorization: Bearer xxx.xxx.xxx" -F "file=@/path/to/file.pdf" ``` ```bash # 3. 使用 token 分享文本 curl -X POST "http://localhost:12345/share/text/" -H "Authorization: Bearer xxx.xxx.xxx" -F "text=这是要分享的文本内容" ``` -------------------------------- ### Docker CLI Deployment (Domestic Mirror) Source: https://github.com/vastsa/filecodebox/blob/master/readme.md Run FileCodeBox using Docker CLI with a domestic mirror image if Docker Hub is slow. Mounts a volume for data persistence and maps the service port. ```bash # 国内镜像(如果 Docker Hub 拉取缓慢) docker run -d --restart always -p 12345:12345 -v /opt/FileCodeBox:/app/data --name filecodebox docker.cnb.cool/aixk/filecodebox ``` -------------------------------- ### Configure Alibaba Cloud OSS Compatible Storage Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/storage.md Sets up FileCodeBox to use Alibaba Cloud Object Storage Service (OSS). Ensure the endpoint URL follows the format https://..aliyuncs.com. ```bash file_storage=s3 s3_access_key_id=您的AccessKeyId s3_secret_access_key=您的SecretAccessKey s3_bucket_name=bucket-name s3_endpoint_url=https://bucket-name.oss-cn-hangzhou.aliyuncs.com s3_region_name=oss-cn-hangzhou s3_signature_version=s3v4 ``` -------------------------------- ### Error Response Example Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Example JSON response for a validation error, detailing the field, message, and error type. ```json { "code": 422, "detail": [ { "loc": ["body", "password"], "msg": "密码不能为空", "type": "value_error" } ] } ``` -------------------------------- ### One-Click Deployment with Docker Source: https://github.com/vastsa/filecodebox/blob/master/readme.md This command deploys FileCodeBox using Docker. It maps port 12345 and persists data in /opt/FileCodeBox. ```bash docker run -d -p 12345:12345 -v /opt/FileCodeBox:/app/data --name filecodebox lanol/filecodebox:latest # 国内镜像(如果上面拉取缓慢): docker.cnb.cool/aixk/filecodebox ``` -------------------------------- ### Docker Run Command for FileCodeBox 2.x (Beta) Source: https://github.com/vastsa/filecodebox/wiki/部署教程 Use this command to run the beta version of FileCodeBox 2.x. It maps port 12345 and mounts a volume for data persistence. Ensure the container is always restarted. ```bash docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta ``` -------------------------------- ### Docker CLI Deployment (Docker Hub) Source: https://github.com/vastsa/filecodebox/blob/master/readme.md Run FileCodeBox using Docker CLI with the official Docker Hub image. Mounts a volume for data persistence and maps the service port. ```bash # Docker Hub(推荐) docker run -d --restart always -p 12345:12345 -v /opt/FileCodeBox:/app/data --name filecodebox lanol/filecodebox:latest ``` -------------------------------- ### Get Statistics Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/management.md Retrieves statistical data for the dashboard. ```APIDOC ## GET /admin/dashboard ### Description Fetches statistical data to be displayed on the admin dashboard. ### Method GET ### Endpoint /admin/dashboard ### Parameters #### Header Parameters - **Authorization** (string) - Required - Bearer token for authentication. ``` -------------------------------- ### Run FileCodeBox with Docker CLI Source: https://github.com/vastsa/filecodebox/blob/master/readme_en.md Deploy FileCodeBox using Docker Hub or a China mirror. Ensure the data volume and port mapping are correctly configured. ```bash # Docker Hub (Recommended) docker run -d --restart always -p 12345:12345 -v /opt/FileCodeBox:/app/data --name filecodebox lanol/filecodebox:latest # China Mirror (if Docker Hub is slow) docker run -d --restart always -p 12345:12345 -v /opt/FileCodeBox:/app/data --name filecodebox docker.cnb.cool/aixk/filecodebox ``` -------------------------------- ### Get Local File List Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/management.md Retrieves a list of files stored locally on the server. ```APIDOC ## GET /admin/local/lists ### Description Fetches a list of files available in the local storage. ### Method GET ### Endpoint /admin/local/lists ### Parameters #### Header Parameters - **Authorization** (string) - Required - Bearer token for authentication. ``` -------------------------------- ### Docker 快速启动 FileCodeBox Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/getting-started.md 使用 Docker 运行 FileCodeBox 的基本命令,将本地目录挂载到容器内作为数据存储,并将主机的 12345 端口映射到容器的 12345 端口。 ```bash docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest ``` -------------------------------- ### General WebDAV Configuration Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/storage.md Basic configuration for WebDAV storage. Ensure all parameters are correctly set for your WebDAV server. ```bash file_storage=webdav webdav_url=https://dav.example.com/remote.php/dav/files/username/ webdav_username=your_username webdav_password=your_password webdav_root_path=filebox_storage ``` -------------------------------- ### Share Text Response Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Example JSON response after successfully sharing text, containing the share code. ```json { "code": 200, "msg": "success", "detail": { "code": "abc123" } } ``` -------------------------------- ### Dashboard - Get Statistics Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/management.md Retrieves statistical data for the dashboard, such as file counts, storage usage, etc. ```APIDOC ## GET /admin/dashboard ### Description Retrieves statistical data for the dashboard, such as file counts, storage usage, etc. ### Method GET ### Endpoint /admin/dashboard ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. ``` -------------------------------- ### Download File Endpoint Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/upload.md Download a file using its extraction code via the GET /share/select/ endpoint. ```APIDOC ## GET /share/select/ ### Description Download a file using its unique extraction code. ### Method GET ### Endpoint /share/select/ ### Parameters #### Query Parameters - **code** (string) - Required - The extraction code of the file to download. ### Request Example ```bash curl -L "http://localhost:12345/share/select/?code=YOUR_CODE" -o downloaded_file ``` ``` -------------------------------- ### Docker 自定义配置启动 FileCodeBox Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/getting-started.md 通过 Docker run 命令启动 FileCodeBox,并自定义环境变量 `WORKERS` 和 `LOG_LEVEL`,同时挂载本地数据卷和映射端口。 ```bash docker run -d --restart=always \ -p 12345:12345 \ -v /opt/FileCodeBox/:/app/data \ -e WORKERS=8 \ -e LOG_LEVEL=warning \ --name filecodebox \ lanol/filecodebox:latest ``` -------------------------------- ### Configure Aliyun OSS Storage Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/storage.md Configure S3-compatible storage for Aliyun OSS. Use the correct access key ID, secret access key, bucket name, and the specific endpoint URL for your region. The signature version should typically be set to s3v4. ```bash file_storage=s3 s3_access_key_id=YourAccessKeyId s3_secret_access_key=YourSecretAccessKey s3_bucket_name=bucket-name s3_endpoint_url=https://bucket-name.oss-cn-hangzhou.aliyuncs.com s3_region_name=oss-cn-hangzhou s3_signature_version=s3v4 ``` -------------------------------- ### Configure Azure Blob Storage with OpenDAL Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/storage.md Set up environment variables for connecting to Azure Blob Storage via OpenDAL. Provide your storage account name and key. ```bash file_storage=opendal opendal_scheme=azblob opendal_azblob_root=/filecodebox opendal_azblob_container=your-container opendal_azblob_account_name=your_account opendal_azblob_account_key=your_key ``` -------------------------------- ### Share Text (Authenticated) Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md cURL example for sharing text content when authentication is required. Requires the Authorization header. ```bash # 需要认证时(openUpload=0 时) curl -X POST "http://localhost:12345/share/text/" \ -H "Authorization: Bearer xxx.xxx.xxx" \ -F "text=这是要分享的文本内容" ``` -------------------------------- ### Small Personal Use Configuration Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/configuration.md Configuration suitable for personal or small team use with relaxed upload limits. Sets a 50MB upload size limit and allows 20 uploads within 5 minutes. ```python { "name": "My File Share", "uploadSize": 52428800, # 50MB "uploadMinute": 5, # 5 minutes "uploadCount": 20, # Max 20 uploads "expireStyle": ["day", "hour", "forever"], "admin_token": "your-secure-password", "showAdminAddr": 1 } ``` -------------------------------- ### Get Local File List API Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/management.md Retrieve a list of files stored locally. Requires a Bearer token. ```http GET /admin/local/lists Authorization: Bearer ``` -------------------------------- ### Get Dashboard Statistics API Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/management.md Retrieve statistics for the dashboard. Requires a valid Bearer token in the Authorization header. ```http GET /admin/dashboard Authorization: Bearer ``` -------------------------------- ### Docker Run Command for FileCodeBox 2.x (Alternative Registry) Source: https://github.com/vastsa/filecodebox/wiki/部署教程 An alternative Docker run command for users experiencing issues with the default registry. This command uses a different image registry for the beta version. ```bash docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox dc.065065.xyz/lanol/filecodebox:beta ``` -------------------------------- ### Configure OneDrive Storage Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/storage.md Set up the necessary parameters for OneDrive storage integration. Ensure you have an Azure AD domain, client ID, username, and password. ```bash file_storage=onedrive onedrive_domain=contoso.onmicrosoft.com onedrive_client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx onedrive_username=user@contoso.onmicrosoft.com onedrive_password=your_password onedrive_root_path=filebox_storage ``` -------------------------------- ### Get File Info Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Retrieve file information using a share code. This endpoint can be used to directly download the file. ```APIDOC ## GET /share/select/ ### Description Get file information by share code (directly download the file). ### Method GET ### Endpoint /share/select/ ### Parameters #### Query Parameters - **code** (string) - Required - The file share code. ### Request Example ```bash # Download file by retrieval code curl -L "http://localhost:12345/share/select/?code=abc123" -o downloaded_file ``` ### Response #### Success Response (200) - **code** (string) - The share code. - **name** (string) - The name of the file. - **size** (integer) - The size of the file in bytes. - **text** (string) - The content of the file or a download link. ``` -------------------------------- ### 普通文件上传接口 Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/upload.md 使用 `multipart/form-data` 格式通过 POST 请求 `/share/file/` 接口上传文件。可以指定文件的过期数值和过期方式。 ```bash # 上传文件(默认1天有效期) curl -X POST "http://localhost:12345/share/file/" -F "file=@/path/to/file.pdf" ``` ```bash # 上传文件并指定有效期(7天) curl -X POST "http://localhost:12345/share/file/" -F "file=@/path/to/file.pdf" -F "expire_value=7" -F "expire_style=day" ``` ```bash # 上传文件并指定有效期(可下载10次) curl -X POST "http://localhost:12345/share/file/" -F "file=@/path/to/file.pdf" -F "expire_value=10" -F "expire_style=count" ``` -------------------------------- ### Contribution Workflow Source: https://github.com/vastsa/filecodebox/blob/master/readme.md Steps for forking the repository, creating a new branch, committing changes, and pushing for a pull request. ```bash # 1. Fork 并克隆 git clone https://github.com/your-username/FileCodeBox.git # 2. 创建分支 git checkout -b feature/your-feature # 3. 提交更改 git commit -m "feat: add your feature" # 4. 推送并创建 PR git push origin feature/your-feature ``` -------------------------------- ### POST /share/select/ Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/share.md Retrieve information about a shared item using its retrieval code. This endpoint can be used to get details for both text and files. ```APIDOC ## POST /share/select/ ### Description Retrieve information about a shared item using its retrieval code. This endpoint can be used to get details for both text and files. ### Method POST ### Endpoint /share/select/ ### Parameters #### Request Body - **code** (string) - Required - The retrieval code for the shared item. ### Response #### Success Response (200) - **code** (int) - The HTTP status code. - **detail** (object) - Contains details about the shared item. - **code** (string) - The retrieval code. - **name** (string) - The name of the item (e.g., 'Text' for text shares). - **size** (int) - The size of the item in bytes. - **text** (string) - A URL for file downloads or the actual text content for text shares. ### Response Example (File) ```json { "code": 200, "detail": { "code": "123456", "name": "example.pdf", "size": 1048576, "text": "https://example.com/download/..." } } ``` ### Response Example (Text) ```json { "code": 200, "detail": { "code": "123456", "name": "Text", "size": 1024, "text": "这是分享的文本内容..." } } ``` ``` -------------------------------- ### 手动部署 FileCodeBox - 启动服务 Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/getting-started.md 使用 Python 运行 `main.py` 文件来启动 FileCodeBox 服务。 ```bash python main.py ``` -------------------------------- ### Get Admin Token Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Use this cURL command to obtain an authentication token when guest uploads are disabled. Requires the admin password. ```bash curl -X POST "http://localhost:12345/admin/login" \ -H "Content-Type: application/json" \ -d '{"password": "<初始化时设置的管理员密码>"}' ``` -------------------------------- ### Configure Google Cloud Storage with OpenDAL Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/storage.md Set up environment variables for connecting to Google Cloud Storage via OpenDAL. Ensure your GCS credential is base64 encoded. ```bash file_storage=opendal opendal_scheme=gcs opendal_gcs_root=/filecodebox opendal_gcs_bucket=your-bucket-name opendal_gcs_credential=base64_encoded_credential ``` -------------------------------- ### GET /share/select/ Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/share.md Directly download a shared file using its retrieval code. This endpoint is suitable for direct browser access to file content. ```APIDOC ## GET /share/select/ ### Description Directly download a shared file using its retrieval code. This endpoint is suitable for direct browser access to file content. ### Method GET ### Endpoint /share/select/ ### Parameters #### Query Parameters - **code** (string) - Required - The retrieval code for the shared file. ### Response #### Success Response (200) - The raw content of the shared file. ### Usage This endpoint returns the file content directly. For example, accessing `GET /share/select/?code=123456` in a browser will initiate the download or display the file if the browser supports it. ``` -------------------------------- ### Direct File Download API Request Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/share.md Use a GET request with the extract code as a query parameter to directly download a file from the browser. ```http GET /share/select/?code=123456 ``` -------------------------------- ### Get File List API Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/management.md Retrieve a paginated list of files. Supports filtering by keyword and pagination parameters. Requires a Bearer token. ```http GET /admin/file/list?page=1&size=10&keyword= Authorization: Bearer ``` -------------------------------- ### 分享文本内容 Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/upload.md 使用 POST 请求 `/share/text/` 接口分享文本内容。文本内容作为 `text` 参数传递。 ```bash # 分享文本 curl -X POST "http://localhost:12345/share/text/" -F "text=这是要分享的文本内容" ``` -------------------------------- ### Docker Run Command for FileCodeBox 1.6 (ARM) Source: https://github.com/vastsa/filecodebox/wiki/部署教程 Command to run FileCodeBox version 1.6 for ARM architecture. It uses the 'arm' tag and persists data to /opt/FileCodeBox/. ```bash docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:arm ``` -------------------------------- ### Configure Local Storage Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/storage.md Use this configuration for the default local storage method. Files are saved in the server's data directory. Ensure the data directory is mounted to persistent storage in production. ```bash file_storage=local storage_path= ``` -------------------------------- ### Select File Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md Select a file using its share code. ```APIDOC ## POST /share/select/ ### Description Select a file by share code. ### Method POST ### Endpoint /share/select/ ### Parameters #### Request Body - **code** (string) - Required - The file share code. ### Response #### Success Response (200) - **code** (string) - The share code. - **name** (string) - The name of the file. - **size** (integer) - The size of the file in bytes. - **text** (string) - The content of the file or a download link. ``` -------------------------------- ### Select File by Code Source: https://github.com/vastsa/filecodebox/blob/master/docs/api/index.md POST request to select a file using its share code. Returns file details. ```http POST /share/select/ HTTP/1.1 Host: localhost:12345 Content-Type: application/json { "code": "abc123" } ``` -------------------------------- ### 修改默认上传大小限制 Source: https://github.com/vastsa/filecodebox/blob/master/docs/guide/upload.md 管理员可以通过修改配置文件中的 `uploadSize` 变量来调整单文件最大上传大小。该值以字节为单位。 ```python # 设置最大上传大小为 100MB uploadSize = 104857600 # 100 * 1024 * 1024 ``` -------------------------------- ### Set Admin Password Format Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/security.md Use this format when setting the admin_token. Ensure your password meets the security recommendations. ```python # Recommended password format example "admin_token": "Xk9#mP2$vL5@nQ8&wR3" ``` -------------------------------- ### Download File Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/management.md Initiates the download of a specific file. ```APIDOC ## GET /admin/file/download ### Description Provides a link or initiates the download for a specified file. ### Method GET ### Endpoint /admin/file/download ### Parameters #### Query Parameters - **id** (integer) - Required - The ID of the file to download. #### Header Parameters - **Authorization** (string) - Required - Bearer token for authentication. ``` -------------------------------- ### Initialize Upload Source: https://github.com/vastsa/filecodebox/blob/master/docs/en/guide/upload.md Initializes a chunked upload session. This endpoint is used to start the upload process for a large file by providing file metadata. It returns an upload ID and information about existing uploads. ```APIDOC ## POST /chunk/upload/init/ ### Description Initializes a chunked upload session. This endpoint is used to start the upload process for a large file by providing file metadata. It returns an upload ID and information about existing uploads. ### Method POST ### Endpoint /chunk/upload/init/ ### Parameters #### Request Body - **file_name** (string) - Yes - Filename - **file_size** (int) - Yes - Total file size (bytes) - **chunk_size** (int) - No - Chunk size (bytes) (Default: 5MB) - **file_hash** (string) - Yes - SHA256 hash of the file ### Response #### Success Response (200) - **existed** (boolean) - Whether file already exists (instant upload) - **upload_id** (string) - Upload session ID - **chunk_size** (int) - Chunk size - **total_chunks** (int) - Total number of chunks - **uploaded_chunks** (array) - List of already uploaded chunk indices ### Response Example ```json { "code": 200, "detail": { "existed": false, "upload_id": "abc123def456789", "chunk_size": 5242880, "total_chunks": 20, "uploaded_chunks": [] } } ``` ```