upload Attachment
Uploads a binary file or screenshot attachment to storage and returns a descriptor ready to be attached to a FeedbackDraft.
Image MIME types (e.g.,
image/png,image/jpeg) are routed toPOST /api/v1/uploads/images.All other files (e.g. logs, crashes, text) are routed to
POST /api/v1/uploads/r2object storage.Use preferredKind to explicitly override the destination storage backend.
Accepts HTTP 200 OK and 201 Created responses. If userToken is provided, it is forwarded as the X-User-Token header to associate the upload with the anonymous user identity.
Return
A populated FeedbackAttachment containing the persisted URL and storage key.
Parameters
Binary payload to upload.
Display file name including extension (e.g. screenshot.png).
MIME content type (e.g. image/png, application/pdf).
Optional explicit FeedbackAttachment.Kind, overriding MIME-based auto-detection.
Optional stable user token (from UserTokenStore) to attribute the upload.
Throws
on HTTP 401.
if the upload succeeded on the server but the response could not be parsed.
if the file upload is rejected (e.g. exceeded maxAttachmentBytes).
if a network error occurs.
Example:
val screenshotBytes = captureViewAsPngBytes(window.decorView)
val attachment = client.uploadAttachment(
data = screenshotBytes,
filename = "device_screenshot.png",
mimeType = "image/png",
userToken = userToken
)
val draft = baseDraft.copy(attachments = listOf(attachment))
client.submit(draft, userToken)