appendBlob

fun FormBuilder.appendBlob(key: String, blob: Blob, headers: Headers = Headers.Empty)(source)

Appends a Blob part with the specified key and optional headers.

This enables sending browser File and Blob objects as multipart form data parts using the Ktor client from Kotlin/JS and Kotlin/WasmJS.

Example:

val file: File = // from <input type="file">
client.submitFormWithBinaryData(url, formData {
appendBlob("document", file)
})

Parameters

key

multipart field name

blob

browser Blob or File payload to send

headers

additional part headers; defaults to empty

Report a problem


fun FormBuilder.appendBlob(key: String, blob: Blob, filename: String, contentType: ContentType? = null)(source)

Appends a Blob part with the specified key, filename, and optional contentType.

This enables uploading browser File and Blob objects with associated filename and content type metadata.

Example:

val file: File = // from <input type="file">
client.submitFormWithBinaryData(url, formData {
appendBlob("document", file, file.name, ContentType.Application.Pdf)
})

Parameters

key

multipart field name

blob

browser Blob or File payload to send

filename

name to set in the Content-Disposition header

contentType

optional content type for the part

Report a problem