# Assets ## Download `client.assets.download(AssetDownloadParamsbody, RequestOptionsoptions?): AssetDownloadResponse` **post** `/v1/assets/download` Download a Matrix asset using its mxc:// or localmxc:// URL to the device running Beeper Desktop and return the local file URL. ### Parameters - `body: AssetDownloadParams` - `url: string` Matrix content URL (mxc:// or localmxc://) for the asset to download. ### Returns - `AssetDownloadResponse` - `error?: string` Error message if the download failed. - `srcURL?: string` Local file URL to the downloaded asset. ### Example ```typescript import BeeperDesktop from '@beeper/desktop-api'; const client = new BeeperDesktop(); const response = await client.assets.download({ url: 'mxc://example.org/Q4x9CqGz1pB3Oa6XgJ' }); console.log(response.error); ``` ## Upload `client.assets.upload(AssetUploadParamsbody, RequestOptionsoptions?): AssetUploadResponse` **post** `/v1/assets/upload` Upload a file to a temporary location using multipart/form-data. Returns an uploadID that can be referenced when sending messages with attachments. ### Parameters - `body: AssetUploadParams` - `file: Uploadable` The file to upload (max 500 MB). - `fileName?: string` Original filename. Defaults to the uploaded file name if omitted - `mimeType?: string` MIME type. Auto-detected from magic bytes if omitted ### Returns - `AssetUploadResponse` - `duration?: number` Duration in seconds (audio/videos) - `error?: string` Error message if upload failed - `fileName?: string` Resolved filename - `fileSize?: number` File size in bytes - `height?: number` Height in pixels (images/videos) - `mimeType?: string` Detected or provided MIME type - `srcURL?: string` Local file URL (file://) for the uploaded asset - `uploadID?: string` Unique upload ID for this asset - `width?: number` Width in pixels (images/videos) ### Example ```typescript import BeeperDesktop from '@beeper/desktop-api'; const client = new BeeperDesktop(); const response = await client.assets.upload({ file: fs.createReadStream('path/to/file') }); console.log(response.width); ``` ## Upload Base64 `client.assets.uploadBase64(AssetUploadBase64Paramsbody, RequestOptionsoptions?): AssetUploadBase64Response` **post** `/v1/assets/upload/base64` Upload a file using a JSON body with base64-encoded content. Returns an uploadID that can be referenced when sending messages with attachments. Alternative to the multipart upload endpoint. ### Parameters - `body: AssetUploadBase64Params` - `content: string` Base64-encoded file content (max ~500MB decoded) - `fileName?: string` Original filename. Generated if omitted - `mimeType?: string` MIME type. Auto-detected from magic bytes if omitted ### Returns - `AssetUploadBase64Response` - `duration?: number` Duration in seconds (audio/videos) - `error?: string` Error message if upload failed - `fileName?: string` Resolved filename - `fileSize?: number` File size in bytes - `height?: number` Height in pixels (images/videos) - `mimeType?: string` Detected or provided MIME type - `srcURL?: string` Local file URL (file://) for the uploaded asset - `uploadID?: string` Unique upload ID for this asset - `width?: number` Width in pixels (images/videos) ### Example ```typescript import BeeperDesktop from '@beeper/desktop-api'; const client = new BeeperDesktop(); const response = await client.assets.uploadBase64({ content: 'x' }); console.log(response.width); ``` ## Serve `client.assets.serve(AssetServeParamsquery, RequestOptionsoptions?): void` **get** `/v1/assets/serve` Stream a file given an mxc://, localmxc://, or file:// URL. Downloads first if not cached. Supports Range requests for seeking in large files. ### Parameters - `query: AssetServeParams` - `url: string` Asset URL to serve. Accepts mxc://, localmxc://, or file:// URLs. ### Example ```typescript import BeeperDesktop from '@beeper/desktop-api'; const client = new BeeperDesktop(); await client.assets.serve({ url: 'x' }); ```