project-files
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill: Project Files
Skill: 项目文件
Description
描述
Manage files in project directories. This skill documents the public API at (PublicApiProjectFileController). Upload flow: 1) POST prepare with directoryId; 2) PUT file to ; 3) POST confirm with . All paths require ; prepare/prepare-update also need . Authenticate with header.
/api/v2/projects/{projectId}upload_urlfile_idprojectIddirectoryIdX-API-KEY管理项目目录中的文件。本Skill记录了路径为的公共API(对应PublicApiProjectFileController)。上传流程:1)携带directoryId发起POST预准备请求;2)将文件PUT到返回的;3)携带发起POST确认请求。所有路径都需要参数;上传/更新预准备接口还需要参数。通过请求头进行鉴权。
/api/v2/projects/{projectId}upload_urlfile_idprojectIddirectoryIdX-API-KEYTypeScript types (request / response)
TypeScript类型定义(请求/响应)
Mirrors data classes.
PublicApiProjectFileControllertypescript
// --- Prepare upload (POST) — 201 ---
type PrepareFileUploadRequest = {
path: string;
file_name: string;
mime_type: string;
size: number;
};
type PrepareFileUploadResponse = {
upload_url: string;
file_id: string;
s3_key: string;
expires_at: string;
};
// --- Prepare update (POST) ---
type PrepareUpdateFileRequest = {
path: string;
mime_type?: string | null;
size?: number | null;
};
type PrepareUpdateFileResponse = {
upload_url: string;
file_id: string;
s3_key: string;
expires_at: string;
};
// --- Confirm (POST) ---
type ConfirmFileUploadRequest = { metadata?: Record<string, unknown> | null };
type FileResponse = {
id: string;
name: string;
file_type: string;
mime_type: string;
s3_key: string;
size: number;
uploaded_at: string;
uploaded_by: string;
status: string;
metadata: Record<string, unknown> | null;
};
// --- Download URL (GET), Get file (GET), Delete (DELETE) ---
type DownloadUrlResponse = {
download_url: string;
expires_at: string;
};与的数据类保持一致。
PublicApiProjectFileControllertypescript
// --- Prepare upload (POST) — 201 ---
type PrepareFileUploadRequest = {
path: string;
file_name: string;
mime_type: string;
size: number;
};
type PrepareFileUploadResponse = {
upload_url: string;
file_id: string;
s3_key: string;
expires_at: string;
};
// --- Prepare update (POST) ---
type PrepareUpdateFileRequest = {
path: string;
mime_type?: string | null;
size?: number | null;
};
type PrepareUpdateFileResponse = {
upload_url: string;
file_id: string;
s3_key: string;
expires_at: string;
};
// --- Confirm (POST) ---
type ConfirmFileUploadRequest = { metadata?: Record<string, unknown> | null };
type FileResponse = {
id: string;
name: string;
file_type: string;
mime_type: string;
s3_key: string;
size: number;
uploaded_at: string;
uploaded_by: string;
status: string;
metadata: Record<string, unknown> | null;
};
// --- Download URL (GET), Get file (GET), Delete (DELETE) ---
type DownloadUrlResponse = {
download_url: string;
expires_at: string;
};Prepare Project File Upload
项目文件上传预准备
Request body: . Response (201): .
PrepareFileUploadRequestPrepareFileUploadResponsebash
curl -X POST "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/directories/<directory_id>/files/prepare" \
-H "Content-Type: application/json" \
-H "X-API-KEY: $LAYERPROOF_API_KEY" \
-d '{"path":"/","file_name":"doc.pdf","mime_type":"application/pdf","size":2048}'请求体:。响应(201):。
PrepareFileUploadRequestPrepareFileUploadResponsebash
curl -X POST "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/directories/<directory_id>/files/prepare" \
-H "Content-Type: application/json" \
-H "X-API-KEY: $LAYERPROOF_API_KEY" \
-d '{"path":"/","file_name":"doc.pdf","mime_type":"application/pdf","size":2048}'Prepare Project File Update
项目文件更新预准备
Request body: . Response: .
PrepareUpdateFileRequestPrepareUpdateFileResponsebash
curl -X POST "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/directories/<directory_id>/files/prepare-update" \
-H "Content-Type: application/json" \
-H "X-API-KEY: $LAYERPROOF_API_KEY" \
-d '{"path":"/doc.pdf","mime_type":"application/pdf","size":2048}'请求体:。响应:。
PrepareUpdateFileRequestPrepareUpdateFileResponsebash
curl -X POST "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/directories/<directory_id>/files/prepare-update" \
-H "Content-Type: application/json" \
-H "X-API-KEY: $LAYERPROOF_API_KEY" \
-d '{"path":"/doc.pdf","mime_type":"application/pdf","size":2048}'Confirm Project File Upload
项目文件上传确认
Request body: . Response: .
ConfirmFileUploadRequestFileResponsebash
curl -X POST "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/files/<file_id>/confirm" \
-H "Content-Type: application/json" \
-H "X-API-KEY: $LAYERPROOF_API_KEY" \
-d '{"metadata":{}}'请求体:。响应:。
ConfirmFileUploadRequestFileResponsebash
curl -X POST "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/files/<file_id>/confirm" \
-H "Content-Type: application/json" \
-H "X-API-KEY: $LAYERPROOF_API_KEY" \
-d '{"metadata":{}}'Get File Download URL
获取文件下载链接
Response: .
DownloadUrlResponsebash
curl "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/files/<file_id>/download-url" \
-H "X-API-KEY: $LAYERPROOF_API_KEY"响应:。
DownloadUrlResponsebash
curl "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/files/<file_id>/download-url" \
-H "X-API-KEY: $LAYERPROOF_API_KEY"Get File Details
获取文件详情
Response: .
FileResponsebash
curl "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/files/<file_id>" \
-H "X-API-KEY: $LAYERPROOF_API_KEY"响应:。
FileResponsebash
curl "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/files/<file_id>" \
-H "X-API-KEY: $LAYERPROOF_API_KEY"Delete Project File
删除项目文件
Response: 204 No Content.
bash
curl -X DELETE "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/files/<file_id>" \
-H "X-API-KEY: $LAYERPROOF_API_KEY"响应:204 No Content。
bash
curl -X DELETE "$LAYERPROOF_BASE_URL/api/v2/projects/<project_id>/files/<file_id>" \
-H "X-API-KEY: $LAYERPROOF_API_KEY"Agent behavior
Agent行为
When the user asks to manage project files (upload, update, confirm, download, delete), do the following.
当用户要求管理项目文件(上传、更新、确认、下载、删除)时,执行以下操作:
1. Choose the right endpoint
1. 选择正确的端点
Base path: . Replace , , as needed.
/api/v2/projects/{projectId}project_iddirectory_idfile_id| User intent | Endpoint | Method |
|---|---|---|
| Get upload URL for new file | | POST |
| Get upload URL to update file | | POST |
| Confirm upload after PUT | | POST |
| Get download URL | | GET |
| Get file metadata | | GET |
| Delete file | | DELETE |
基础路径:,按需替换、、参数。
/api/v2/projects/{projectId}project_iddirectory_idfile_id| 用户意图 | 端点 | 请求方法 |
|---|---|---|
| 获取新文件的上传地址 | | POST |
| 获取更新文件的上传地址 | | POST |
| PUT上传完成后确认操作 | | POST |
| 获取下载链接 | | GET |
| 获取文件元数据 | | GET |
| 删除文件 | | DELETE |
2. Build and run the request
2. 构造并执行请求
- Auth: Include . Read env vars; if missing, tell the user.
X-API-KEY: $LAYERPROOF_API_KEY - Path: Resolve projectId, directoryId, fileId from context or user input.
- POST: Build JSON body from types above; run curl and show result.
- GET/DELETE: Build path only; run curl and show result.
- 鉴权:请求头需携带,读取环境变量,若变量不存在则告知用户。
X-API-KEY: $LAYERPROOF_API_KEY - 路径:从上下文或用户输入中解析projectId、directoryId、fileId参数。
- POST请求:根据上述类型定义构造JSON请求体,执行curl命令并展示结果。
- GET/DELETE请求:仅构造请求路径,执行curl命令并展示结果。
3. Upload flow
3. 上传流程
Prepare → PUT file to → confirm with . Then use for get/download/delete.
upload_urlfile_idfile_id预准备 → 将文件PUT到 → 携带确认。后续可使用执行查询、下载、删除操作。
upload_urlfile_idfile_id4. Response handling
4. 响应处理
- Always show raw JSON in a code block; show image + JSON if image URL present.
- On error, show body and status code.
- 始终在代码块中展示原始JSON;若返回图片URL则同时展示图片和JSON。
- 请求出错时,展示响应体和状态码。
5. Example workflows
5. 示例工作流
Workflow A — User: "Upload a PDF to project X in the root directory."
- Resolve projectId and directoryId (e.g. root directory from project or list directories). POST with
.../directories/{directoryId}/files/prepare; get{"path":"/","file_name":"brief.pdf","mime_type":"application/pdf","size":<bytes>},upload_url,file_id.s3_key - Tell user to PUT the file to with
upload_url. Then POSTContent-Type: application/pdfwith.../files/{file_id}/confirm(or{}).{"metadata":{}} - Show JSON; use for later get/download/delete.
file_id
Workflow B — User: "Upload two reference docs to the project, then use them when generating the slide deck outline."
- For each file: prepare with path (e.g. ,
/ref1.pdf) → user uploads to/ref2.docx→ confirm. Capture bothupload_urlandfile_id(if returned) for each.s3_key - If outline generation accepts project file references: pass the project file identifiers (e.g. s3_keys or file_ids) into the slide-deck outline/generate request (e.g. or equivalent). Otherwise use public-files for outline references and keep project files for project-scoped use only.
file_s3_keys - Hand off to slide-decks: POST outline/generate with the resolved keys; poll job; get deck.
Workflow C — User: "Update an existing file in the project (new version) and get a download URL after."
- Resolve projectId, directoryId, and existing file path. POST with
.../directories/{directoryId}/files/prepare-update; get{"path":"/brief.pdf","mime_type":"application/pdf","size":<new_bytes>},upload_url.file_id - User PUTs new content to ; then POST
upload_url. GET.../files/{file_id}/confirmto show the user a temporary download link..../files/{file_id}/download-url - On error (e.g. path not found), show response body and suggest verifying path and project/directory IDs.
工作流A — 用户:"上传一份PDF到X项目的根目录。"
- 解析projectId和directoryId(例如从项目信息中获取根目录ID,或调用接口查询目录列表)。携带参数发起POST请求到
{"path":"/","file_name":"brief.pdf","mime_type":"application/pdf","size":<bytes>},获取.../directories/{directoryId}/files/prepare、upload_url、file_id。s3_key - 告知用户将文件PUT到,请求头需携带
upload_url,完成后携带Content-Type: application/pdf(或{})发起POST请求到{"metadata":{}}完成确认。.../files/{file_id}/confirm - 展示JSON响应,后续可使用执行查询、下载、删除操作。
file_id
工作流B — 用户:"上传两份参考文档到项目中,后续生成幻灯片大纲时需要用到这些文档。"
- 逐个处理文件:携带路径(例如、
/ref1.pdf)发起预准备请求 → 用户上传文件到/ref2.docx→ 确认上传。记录每个文件的upload_url和file_id(如果返回)。s3_key - 如果大纲生成接口支持传入项目文件引用:将项目文件标识(例如s3_keys或file_ids)传入幻灯片大纲生成请求(对应参数或等效参数)。否则使用公共文件作为大纲引用,项目文件仅在项目范围内使用。
file_s3_keys - 流转到幻灯片生成模块:携带解析后的标识发起大纲生成POST请求,轮询任务状态,获取生成的幻灯片。
工作流C — 用户:"更新项目中的现有文件(新版本),完成后获取下载链接。"
- 解析projectId、directoryId和现有文件路径。携带参数发起POST请求到
{"path":"/brief.pdf","mime_type":"application/pdf","size":<new_bytes>},获取.../directories/{directoryId}/files/prepare-update、upload_url。file_id - 用户将新内容PUT到,之后发起POST请求到
upload_url完成确认。发起GET请求到.../files/{file_id}/confirm,向用户返回临时下载链接。.../files/{file_id}/download-url - 请求出错时(例如路径不存在),展示响应体,建议用户校验路径和项目/目录ID是否正确。
Response format (required)
响应格式(必填)
- (if response contains url to show image) please show image and show json response instead of table
- Always show the raw JSON response (verbatim) in a JSON code block.
- If the response contains a URL for an image, render/show the image and also show the JSON response (do not convert to a table).
- 如果响应包含图片展示URL,请同时展示图片和JSON响应,不要使用表格。
- 始终在JSON代码块中展示原始JSON响应(逐字保留)。
- 如果响应包含图片URL,请渲染/展示图片同时展示JSON响应(不要转换为表格)。