Skip to content
Download Beeper

Upload an asset

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.

ParametersExpand Collapse
body AssetUploadParams
File param.Field[Reader]

The file to upload (max 500 MB).

FileName param.Field[string]Optional

Original filename. Defaults to the uploaded file name if omitted

MimeType param.Field[string]Optional

MIME type. Auto-detected from magic bytes if omitted

ReturnsExpand Collapse
type AssetUploadResponse struct{…}
Duration float64Optional

Duration in seconds (audio/videos)

Error stringOptional

Error message if upload failed

FileName stringOptional

Resolved filename

FileSize float64Optional

File size in bytes

Height float64Optional

Height in pixels (images/videos)

MimeType stringOptional

Detected or provided MIME type

SrcURL stringOptional

Local file URL (file://) for the uploaded asset

UploadID stringOptional

Unique upload ID for this asset

Width float64Optional

Width in pixels (images/videos)

Upload an asset

package main

import (
  "bytes"
  "context"
  "fmt"
  "io"

  "github.com/beeper/desktop-api-go"
  "github.com/beeper/desktop-api-go/option"
)

func main() {
  client := beeperdesktopapi.NewClient(
    option.WithAccessToken("My Access Token"),
  )
  response, err := client.Assets.Upload(context.TODO(), beeperdesktopapi.AssetUploadParams{
    File: io.Reader(bytes.NewBuffer([]byte("Example data"))),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Width)
}
{
  "duration": 0,
  "error": "error",
  "fileName": "fileName",
  "fileSize": 0,
  "height": 0,
  "mimeType": "mimeType",
  "srcURL": "srcURL",
  "uploadID": "uploadID",
  "width": 0
}
Returns Examples
{
  "duration": 0,
  "error": "error",
  "fileName": "fileName",
  "fileSize": 0,
  "height": 0,
  "mimeType": "mimeType",
  "srcURL": "srcURL",
  "uploadID": "uploadID",
  "width": 0
}