# Assets ## Download `client.Assets.Download(ctx, body) (*AssetDownloadResponse, error)` **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 param.Field[string]` Matrix content URL (mxc:// or localmxc://) for the asset to download. ### Returns - `type AssetDownloadResponse struct{…}` - `Error string` Error message if the download failed. - `SrcURL string` Local file URL to the downloaded asset. ### Example ```go package main import ( "context" "fmt" "github.com/beeper/desktop-api-go" ) func main() { client := beeperdesktopapi.NewClient( ) response, err := client.Assets.Download(context.TODO(), beeperdesktopapi.AssetDownloadParams{ URL: "mxc://example.org/Q4x9CqGz1pB3Oa6XgJ", }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Error) } ``` ## Upload `client.Assets.Upload(ctx, body) (*AssetUploadResponse, error)` **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 param.Field[Reader]` The file to upload (max 500 MB). - `FileName param.Field[string]` Original filename. Defaults to the uploaded file name if omitted - `MimeType param.Field[string]` MIME type. Auto-detected from magic bytes if omitted ### Returns - `type AssetUploadResponse struct{…}` - `Duration float64` Duration in seconds (audio/videos) - `Error string` Error message if upload failed - `FileName string` Resolved filename - `FileSize float64` File size in bytes - `Height float64` 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 float64` Width in pixels (images/videos) ### Example ```go package main import ( "bytes" "context" "fmt" "io" "github.com/beeper/desktop-api-go" ) func main() { client := beeperdesktopapi.NewClient( ) response, err := client.Assets.Upload(context.TODO(), beeperdesktopapi.AssetUploadParams{ File: io.Reader(bytes.NewBuffer([]byte("some file contents"))), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Width) } ``` ## Upload Base64 `client.Assets.UploadBase64(ctx, body) (*AssetUploadBase64Response, error)` **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 param.Field[string]` Base64-encoded file content (max ~500MB decoded) - `FileName param.Field[string]` Original filename. Generated if omitted - `MimeType param.Field[string]` MIME type. Auto-detected from magic bytes if omitted ### Returns - `type AssetUploadBase64Response struct{…}` - `Duration float64` Duration in seconds (audio/videos) - `Error string` Error message if upload failed - `FileName string` Resolved filename - `FileSize float64` File size in bytes - `Height float64` 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 float64` Width in pixels (images/videos) ### Example ```go package main import ( "context" "fmt" "github.com/beeper/desktop-api-go" ) func main() { client := beeperdesktopapi.NewClient( ) response, err := client.Assets.UploadBase64(context.TODO(), beeperdesktopapi.AssetUploadBase64Params{ Content: "x", }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Width) } ``` ## Serve `client.Assets.Serve(ctx, query) error` **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 param.Field[string]` Asset URL to serve. Accepts mxc://, localmxc://, or file:// URLs. ### Example ```go package main import ( "context" "github.com/beeper/desktop-api-go" ) func main() { client := beeperdesktopapi.NewClient( ) err := client.Assets.Serve(context.TODO(), beeperdesktopapi.AssetServeParams{ URL: "x", }) if err != nil { panic(err.Error()) } } ```