Topolo Docs Topolo Platform
Open workspace

Prepare file upload

Prepare an authenticated PUT upload session for a positive-size file up to 104857600 bytes (100 MiB). The returned key may be renamed to avoid a collision.

Outcome

Prepare an authenticated PUT upload session for a positive-size file up to 104857600 bytes (100 MiB). The returned key may be renamed to avoid a collision.

Before you start

  • Verify identity, pin environment and organization, and discover a granted Bytes workspace before choosing file keys.
  • The action requires files:write. Select a verified workspace resource separately from action input; a body field cannot supply a workspace grant.
  • Scope org uses the verified workspace shared root; private uses the caller’s private subtree. The accepted legacy all value resolves to org and does not grant cross-organization browsing. The bucket input cannot switch the configured R2 binding.
  • Authorize the described effect or private-data export before passing CLI --confirm or MCP confirm:true. GET listing/search can persist derived data; HTTP method alone does not establish a read-only action.

Discover the target

topolo whoami --json
topolo actions get app_topolo_bytes.files.upload_url.create --detail --json
topolo resources topolo-bytes --json
topolo workspaces list topolo-bytes --json
  • File keys are paths returned by files.list/search in the selected workspace and scope. Discover the granted workspace id; do not derive access from fixture ids.

Request

POST /api/upload-url

Save action input as payload.json. The reviewed plan separates path identifiers, query fields and the HTTP body. Set BYTES_WORKSPACE_ID from granted resource discovery.

Inspect and test this action in the signed action console. A test response still requires the verification below.

Input fields

FieldRequiredTypeConstraints
keyRequiredstring{"minLength":1}
typeRequiredstring{"minLength":1}
sizeRequiredinteger{"maximum":104857600}
bucketOptionalstring{"minLength":1}
scopeOptionalstring{"enum":["org","private","all"]}

Exact input schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "key": {
      "type": "string",
      "minLength": 1
    },
    "type": {
      "type": "string",
      "minLength": 1
    },
    "size": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 104857600
    },
    "bucket": {
      "type": "string",
      "minLength": 1
    },
    "scope": {
      "type": "string",
      "enum": [
        "org",
        "private",
        "all"
      ]
    }
  },
  "required": [
    "key",
    "type",
    "size"
  ],
  "additionalProperties": false
}

Effects

  • Returns an upload URL, PUT method, credential-bearing headers and selected key. Preparing the session does not upload the file.

Interpret the response

The response identifier path is $.key for file. An empty list does not discover a target.

Send the actual bytes through the SDK upload workflow, then list and read the resulting file. A session response alone proves no persisted bytes.

The schema describes supported success fields; optional metadata and integration-dependent values may vary. Errors have the exact shapes shown in refused examples.

Success schema:

{
  "type": "object",
  "required": [
    "url",
    "method",
    "headers",
    "key"
  ],
  "properties": {
    "url": {
      "type": "string"
    },
    "method": {
      "type": "string"
    },
    "headers": {
      "type": "object",
      "required": [
        "content-type",
        "authorization",
        "x-topolo-resource-type",
        "x-topolo-resource-id"
      ],
      "properties": {
        "content-type": {
          "type": "string"
        },
        "authorization": {
          "type": "string"
        },
        "x-topolo-resource-type": {
          "type": "string"
        },
        "x-topolo-resource-id": {
          "type": "string"
        }
      }
    },
    "key": {
      "type": "string"
    }
  }
}

Worked examples

Actual exported Worker handlers with local Miniflare R2/KV. Auth, workspace grants, R2 multipart, notification, usage and semantic integrations are simulated at their configured test boundaries. Synthetic ids, timestamps and signed URLs confer no live access. No deployed provider outcome, external delivery or live grant is established. Upload-session credential values are explicitly redacted; binary responses use the tested SDK transport envelope. Replace synthetic identifiers through credential-scoped discovery. Refused scenarios document failure boundaries; they are not successful workflows.

Successful request

Actual worker response with local Miniflare R2/KV and simulated Auth, workspace grants and outbound integration boundaries. No authorization header is captured. Returned synthetic upload credentials are explicitly redacted in this documented response.

Input · payload.json:

{
  "key": "pic.png",
  "type": "image/png",
  "size": 3
}

CLI:

topolo actions validate app_topolo_bytes.files.upload_url.create --data @payload.json --json
topolo actions plan app_topolo_bytes.files.upload_url.create --resource-type workspace --resource-id "$BYTES_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_bytes.files.upload_url.create --resource-type workspace --resource-id "$BYTES_WORKSPACE_ID" --data @payload.json --confirm --json

MCP tool and arguments:

{
  "tool": "topolo_call_action",
  "arguments": {
    "actionId": "app_topolo_bytes.files.upload_url.create",
    "input": {
      "key": "pic.png",
      "type": "image/png",
      "size": 3
    },
    "resourceType": "workspace",
    "resourceId": "<identifier returned by granted resource discovery>",
    "confirm": true
  }
}

Captured local response · HTTP 200:

{
  "url": "https://bytes-api.test.local/api/upload/pic.png?bucket=topolo-bytes-test&scope=org",
  "method": "PUT",
  "headers": {
    "content-type": "image/png",
    "authorization": "<redacted synthetic upload-session credential>",
    "x-topolo-resource-type": "workspace",
    "x-topolo-resource-id": "workspace_acme"
  },
  "key": "pic.png"
}

HTTP 200. Send the actual bytes through the SDK upload workflow, then list and read the resulting file. A session response alone proves no persisted bytes.

Another supported request

Actual worker response with local Miniflare R2/KV and simulated Auth, workspace grants and outbound integration boundaries. No authorization header is captured. Returned synthetic upload credentials are explicitly redacted in this documented response.

Input · payload.json:

{
  "key": "dupe.txt",
  "type": "text/plain",
  "size": 1
}

CLI:

topolo actions validate app_topolo_bytes.files.upload_url.create --data @payload.json --json
topolo actions plan app_topolo_bytes.files.upload_url.create --resource-type workspace --resource-id "$BYTES_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_bytes.files.upload_url.create --resource-type workspace --resource-id "$BYTES_WORKSPACE_ID" --data @payload.json --confirm --json

MCP tool and arguments:

{
  "tool": "topolo_call_action",
  "arguments": {
    "actionId": "app_topolo_bytes.files.upload_url.create",
    "input": {
      "key": "dupe.txt",
      "type": "text/plain",
      "size": 1
    },
    "resourceType": "workspace",
    "resourceId": "<identifier returned by granted resource discovery>",
    "confirm": true
  }
}

Captured local response · HTTP 200:

{
  "url": "https://bytes-api.test.local/api/upload/dupe%20(2).txt?bucket=topolo-bytes-test&scope=org",
  "method": "PUT",
  "headers": {
    "content-type": "text/plain",
    "authorization": "<redacted synthetic upload-session credential>",
    "x-topolo-resource-type": "workspace",
    "x-topolo-resource-id": "workspace_acme"
  },
  "key": "dupe (2).txt"
}

HTTP 200. Send the actual bytes through the SDK upload workflow, then list and read the resulting file. A session response alone proves no persisted bytes.

Another supported request

Actual worker response with local Miniflare R2/KV and simulated Auth, workspace grants and outbound integration boundaries. No authorization header is captured. Returned synthetic upload credentials are explicitly redacted in this documented response.

Input · payload.json:

{
  "key": "scoped.txt",
  "type": "text/plain",
  "size": 14
}

CLI:

topolo actions validate app_topolo_bytes.files.upload_url.create --data @payload.json --json
topolo actions plan app_topolo_bytes.files.upload_url.create --resource-type workspace --resource-id "$BYTES_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_bytes.files.upload_url.create --resource-type workspace --resource-id "$BYTES_WORKSPACE_ID" --data @payload.json --confirm --json

MCP tool and arguments:

{
  "tool": "topolo_call_action",
  "arguments": {
    "actionId": "app_topolo_bytes.files.upload_url.create",
    "input": {
      "key": "scoped.txt",
      "type": "text/plain",
      "size": 14
    },
    "resourceType": "workspace",
    "resourceId": "<identifier returned by granted resource discovery>",
    "confirm": true
  }
}

Captured local response · HTTP 200:

{
  "url": "https://bytes-api.test.local/api/upload/scoped.txt?bucket=topolo-bytes-test&scope=org",
  "method": "PUT",
  "headers": {
    "content-type": "text/plain",
    "authorization": "<redacted synthetic upload-session credential>",
    "x-topolo-resource-type": "workspace",
    "x-topolo-resource-id": "workspace_acme_uploads"
  },
  "key": "scoped.txt"
}

HTTP 200. Send the actual bytes through the SDK upload workflow, then list and read the resulting file. A session response alone proves no persisted bytes.

Refused request · HTTP 400

Actual worker response with local Miniflare R2/KV and simulated Auth, workspace grants and outbound integration boundaries. No authorization header is captured.

Input · payload.json:

{
  "key": "a.txt"
}

CLI:

topolo actions validate app_topolo_bytes.files.upload_url.create --data @payload.json --json
topolo actions plan app_topolo_bytes.files.upload_url.create --resource-type workspace --resource-id "$BYTES_WORKSPACE_ID" --data @payload.json --json

Captured local response · HTTP 400:

{
  "error": "Missing key or type"
}

HTTP 400. This request was refused; preserve the exact response and correct its cause before retrying.

Refused request · HTTP 413

Actual worker response with local Miniflare R2/KV and simulated Auth, workspace grants and outbound integration boundaries. No authorization header is captured.

Input · payload.json:

{
  "key": "too-large.bin",
  "type": "application/octet-stream",
  "size": 104857601
}

CLI:

topolo actions validate app_topolo_bytes.files.upload_url.create --data @payload.json --json
topolo actions plan app_topolo_bytes.files.upload_url.create --resource-type workspace --resource-id "$BYTES_WORKSPACE_ID" --data @payload.json --json

Captured local response · HTTP 413:

{
  "error": "Upload exceeds the 100 MB limit."
}

HTTP 413. This request was refused; preserve the exact response and correct its cause before retrying.

Verify the result

  • Send the actual bytes through the SDK upload workflow, then list and read the resulting file. A session response alone proves no persisted bytes.

Errors and recovery

  • Missing key or type (HTTP 400): Correct the exact fields using the discovered input schema and prerequisites. Refused input examples demonstrate errors and must not be executed as successful workflows.
  • Upload exceeds the 100 MB limit. (HTTP 413): Correct the exact fields using the discovered input schema and prerequisites. Refused input examples demonstrate errors and must not be executed as successful workflows.

Authentication, the action-input validator or resource middleware can refuse a request before this handler. Preserve the exact request id, error and selected credential context. The fixtures establish no live credentials or configured provider.

Recovery boundary

If bytes have been uploaded, deletion is a separate irreversible action. Otherwise abandon the unexecuted session.

  • List files: List one page of files and directories in the verified workspace; eligible files can have derived thumbnails generated during listing.

Evidence

Actual exported Worker handlers with local Miniflare R2/KV. Auth, workspace grants, R2 multipart, notification, usage and semantic integrations are simulated at their configured test boundaries. Synthetic ids, timestamps and signed URLs confer no live access. No deployed provider outcome, external delivery or live grant is established. Upload-session credential values are explicitly redacted; binary responses use the tested SDK transport envelope. Capture digests and test scenarios are retained in the source fixture records.