uploadAttachment

suspend fun uploadAttachment(data: ByteArray, filename: String, mimeType: String, preferredKind: FeedbackAttachment.Kind? = null): FeedbackAttachment(source)

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 to POST /api/v1/uploads/images.

  • All other files (e.g. logs, crashes, text) are routed to POST /api/v1/uploads/r2 object storage.

  • Use preferredKind to explicitly override the destination storage backend.

Return

FeedbackAttachment containing the CDN URL and storage key.

Parameters

data

Raw binary bytes of the file.

filename

Suggested original filename (e.g. "screenshot.png", "logcat.txt").

mimeType

Standard MIME type string (e.g. "image/png", "text/plain").

preferredKind

Optional storage destination override (FeedbackAttachment.Kind).

Throws

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"
)
val draft = baseDraft.copy(attachments = listOf(attachment))
client.submit(draft, userToken)