Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/foxcapades/lib-k-multipart

Kotlin MultiPart BodyPublisher for the JDK HttpClient API.
https://github.com/foxcapades/lib-k-multipart

http httpclient jdk11 kotlin multipart multipart-formdata multipart-uploads

Last synced: 5 days ago
JSON representation

Kotlin MultiPart BodyPublisher for the JDK HttpClient API.

Awesome Lists containing this project

README

        

= K-MultiPart
:source-highlighter: highlightjs
:lib-version: 1.2.1

image:https://img.shields.io/github/license/foxcapades/lib-k-multipart[GitHub]
image:https://img.shields.io/badge/docs-dokka-violet[link="https://foxcapades.github.io/lib-k-multipart/dokka/1.2.0/"]
image:https://img.shields.io/badge/jvm-11-purple[Java 11]
image:https://img.shields.io/maven-central/v/io.foxcapades.lib/k-multipart[Maven Central, link="https://search.maven.org/artifact/io.foxcapades.lib/k-multipart"]

Kotlin `multipart/form-data` `BodyPublisher` implementation for the
link:https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html[Java `HttpClient` API].

.build.gradle.kts
[source, kotlin, subs="verbatim,attributes"]
----
implementation("io.foxcapades.lib:k-multipart:{lib-version}")
----

== Usage

[source,kotlin]
----
fun main(args: Array) {
val client = HttpClient.newHttpClient()

val body = MultiPart.createBody {
withPart {
fieldName = "foo"
withBody("bar")
}

withPart {
fieldName = "fizz"
withBody(File("buzz"))
}
}

client.send(
HttpRequest.newBuilder(URI(args[0]))
.POST(body)
.build(),
HttpResponse.BodyHandlers.discarding()
)
}
----

== Releases

[%header, cols="1,1,6a"]
|===
| Version | Docs | Notes

| v1.2.1
| link:https://foxcapades.github.io/lib-k-multipart/dokka/1.2.0/[Dokka]
| * Corrects issue with encoding of wide unicode characters.
* Adds optional charset indicator for overall request body.

| v1.2.0
| link:https://foxcapades.github.io/lib-k-multipart/dokka/1.2.0/[Dokka]
| Adds new extension/mixin methods for the `HttpRequest.Builder` type allowing
direct publishing of `MultiPartBody` instances.

| v1.1.0
| link:https://foxcapades.github.io/lib-k-multipart/dokka/1.1.0/[Dokka]
| Adds new methods to enable non-Kotlin JVM languages to use this library.

| v1.0.1
| link:https://foxcapades.github.io/lib-k-multipart/dokka/1.0.0/[Dokka]
| Fixes content-type detection for file body parts.

| v1.0.0
| link:https://foxcapades.github.io/lib-k-multipart/dokka/1.0.0/[Dokka]
| Initial release.
|===