create_upload
Prepare a file upload
Prepares the upload of a file you hold that has no public URL: a file the user attached that your code sandbox can read, or a file on this machine. 1) Measure it: its exact size in bytes and its SHA-256 in hex (wc -c < FILE; shasum -a 256 FILE or sha256sum FILE; on Windows, Get-FileHash -Algorithm SHA256). 2) Call this tool with the name it gets in the Drive, its size and its SHA-256. 3) Within 10 minutes, run the returned command with /path/to/file replaced by the file's path, inside its single quotes, with any ' in the path written as '\'', and change nothing else (your host may ask the user to approve it once). If your host cannot run it, ask the user to run it: never send the request another way. It fetches awen's upload script and sends the raw bytes to upload_host, and the upload completes only with the exact file you measured. If it stops at a refusal, next_steps says what to do for its code. Without a POSIX shell, send the same requests to upload_url with the authorization. 4) Within 30 minutes, call import_file with the same project_id and folder_id and this upload_id to place the file; an upload not placed by then is deleted. For several files, prepare every file, run every command, then place each upload with import_file: each keeps its own times. The command needs network access to script_host for the script, then to upload_host for the file. If curl cannot reach script_host it prints only its own error: ask the user to allow both hosts. Otherwise, when the command fails, its last line, starting with awen:, says what to do next. Drive takes files up to 512 MB, images up to 95 MB and any video, never programs. Only an MP4 opens as a video in awen: other formats save as plain files.
- Permission:
awen:write - Also an API operation:
POST /api/v1/create_upload
Arguments
| Argument | Type | Required | What it is |
|---|---|---|---|
project_id | string | Yes | The project's project_id. |
folder_id | "root" | string | No | "root" (the default), or the entry_id of the folder the file goes in. |
name | string | Yes | The file's name in the Drive, with the extension that sets its type, as in an upload in awen. |
size_bytes | integer | Yes | The file's exact size in bytes. |
sha256 | string | Yes | The SHA-256 of the whole file, in hex. |
Call
A host sends a tools/call request to the MCP endpoint, with the arguments it needs.
{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "create_upload", "arguments": { "project_id": "<string>", "name": "<string>", "size_bytes": "<integer>", "sha256": "<string>" } }}Arguments schema
{ "type": "object", "properties": { "project_id": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_-]+$", "description": "The project's project_id." }, "folder_id": { "description": "\"root\" (the default), or the entry_id of the folder the file goes in.", "anyOf": [ { "type": "string", "const": "root" }, { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_-]+$" } ] }, "name": { "type": "string", "minLength": 1, "maxLength": 2083, "pattern": "^[^\\x00]*$", "description": "The file's name in the Drive, with the extension that sets its type, as in an upload in awen." }, "size_bytes": { "type": "integer", "minimum": 1, "maximum": 536870912, "description": "The file's exact size in bytes." }, "sha256": { "type": "string", "pattern": "^[0-9A-Fa-f]{64}$", "description": "The SHA-256 of the whole file, in hex." } }, "required": [ "project_id", "name", "size_bytes", "sha256" ]}Answer
The answer's structuredContent follows this schema, and its text holds the same JSON.
{ "type": "object", "properties": { "upload_id": { "type": "string" }, "expires_at": { "type": "string" }, "place_within_minutes": { "type": "number" }, "upload_host": { "type": "string" }, "script_host": { "type": "string" }, "upload_url": { "type": "string" }, "authorization": { "type": "string" }, "part_size": { "type": "number" }, "part_count": { "type": "number" }, "command": { "type": "string" }, "next_steps": { "type": "array", "items": { "type": "object", "properties": { "codes": { "type": "array", "items": { "type": "string" } }, "instruction": { "type": "string" } }, "required": [ "codes", "instruction" ], "additionalProperties": false } } }, "required": [ "upload_id", "expires_at", "place_within_minutes", "upload_host", "script_host", "upload_url", "authorization", "part_size", "part_count", "command", "next_steps" ], "additionalProperties": false}