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()).
Public Methods ​
| Method | Description |
|---|---|
| __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() ​
Arguments ​
$urlValidator
consumeFile() ​
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.
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.
Arguments ​
$id$stream(resource)
Returns ​
integer – The number of bytes stored.
Constants ​
| Constant | Description |
|---|---|
MaxRedirects | |
UploadIdPattern | |
UploadTtl |