-
Notifications
You must be signed in to change notification settings - Fork 369
Open
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels