Skip to content

Document appendBlob for JS multipart form data: KTOR-1915 #772

@e5l

Description

@e5l

Context

PR: ktorio/ktor#5390
Issue: https://youtrack.jetbrains.com/issue/KTOR-1915

What changed

New JS-specific FormBuilder.appendBlob() extension functions were added to enable browser file uploads via the Ktor client multipart API. Previously, there was no way to create PartData from org.w3c.files.File or org.w3c.files.Blob in Kotlin/JS, making the documented multipart API unusable from browser environments.

What should be documented

The multipart form data request documentation should include a JS-specific section or note explaining how to upload files from a browser using appendBlob. The relevant module is ktor-client-core, specifically the io.ktor.client.request.forms package.

Suggested code snippet

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

// Upload a raw Blob
val blob: Blob = // any Blob instance
client.submitFormWithBinaryData(url, formData {
    appendBlob("data", blob)
})

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions