Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yskszk63/jnhttp-multipartformdata-bodypublisher
java.net.HttpClient multipart/form-data BodyPublisher
https://github.com/yskszk63/jnhttp-multipartformdata-bodypublisher
http http-client multipart-formdata
Last synced: 6 days ago
JSON representation
java.net.HttpClient multipart/form-data BodyPublisher
- Host: GitHub
- URL: https://github.com/yskszk63/jnhttp-multipartformdata-bodypublisher
- Owner: yskszk63
- License: apache-2.0
- Created: 2021-06-05T08:57:53.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-11T23:41:48.000Z (about 2 years ago)
- Last Synced: 2024-06-21T08:27:33.527Z (5 months ago)
- Topics: http, http-client, multipart-formdata
- Language: Java
- Homepage: https://yskszk63.github.io/jnhttp-multipartformdata-bodypublisher/
- Size: 176 KB
- Stars: 11
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# java.net.HttpClient multipart/form-data BodyPublisher
[![codecov](https://codecov.io/gh/yskszk63/jnhttp-multipartformdata-bodypublisher/branch/main/graph/badge.svg?token=KYD3EHTNI4)](https://codecov.io/gh/yskszk63/jnhttp-multipartformdata-bodypublisher)
[API Document](https://yskszk63.github.io/jnhttp-multipartformdata-bodypublisher/)
## Dependency
```xml
io.github.yskszk63
jnhttp-multipartformdata-bodypublisher
0.0.1
```or copy from [MultipartFormDataBodyPublisher.java](https://github.com/yskszk63/jnhttp-multipartformdata-bodypublisher/blob/main/src/main/java/io/github/yskszk63/jnhttpmultipartformdatabodypublisher/MultipartFormDataBodyPublisher.java).
## Example
```java
var body = new MultipartFormData()
.add(StringPart("name", "Hello,")
.add(StringPart("value", "World!")
.addFile("f", Path.of("index.html"), "text/html")
.addFile("cpuinfo", Path.of("/proc/cpuinfo"), "text/html");var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("http://localhost:8080/"))
.header("Content-Type", body.contentType())
.POST(body)
.build();
var response = client.send(request, BodyHandlers.ofLines());
response.body().forEach(line -> System.out.println(line));
```## License
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.