Skip to content

AssetUploads ​

Type
Class
Namespace
craft\mcp
Inherits
craft\mcp\AssetUploads

Turns client file references into bounded, temporary files for asset persistence.

A file reference provides exactly one source: download_url (a public HTTPS URL), data (base64-encoded contents), path (a local file, for the stdio server only), or upload_id (a file sent to an upload URL from createUpload()).

View source

Public Methods ​

MethodDescription
__construct()
consumeFile()
createUpload()Reserves an upload for the user, returning a single-use URL that accepts the file as a raw PUT request body.
receiveUpload()Stores a request body for a reserved upload.

__construct() ​

View source

Arguments ​

  • $urlValidator

consumeFile() ​

View source

Arguments ​

  • $file (array<string,mixed>)
  • $filename
  • $callback (callable) – Receives the temporary file path, which is deleted afterward, and the filename.

createUpload() ​

Reserves an upload for the user, returning a single-use URL that accepts the file as a raw PUT request body.

View source

Arguments ​

  • $user
  • $baseUrl

Returns ​

array{upload_id: string, upload_url: string, method: string, expires_at: string, max_size: int}

receiveUpload() ​

Stores a request body for a reserved upload.

View source

Arguments ​

Returns ​

integer – The number of bytes stored.

Constants ​

ConstantDescription
MaxRedirects
UploadIdPattern
UploadTtl