Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7610-MicroProfile 7.0 ID-012 #7763

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions modules/ROOT/pages/send-receive-multipart-jaxrs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,63 +45,6 @@ buildscript {
}
----

[#multipart]
== Processing multipart data

The `multipart/form-data` media type enables requests to send multiple entities (parts) as a single entity using `jakarta.ws.rs.core.EntityPart` objects.

For example, MicroProfile Multipart Rest Clients are defined as Java interfaces.

[source,java]
----
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.MULTIPART_FORM_DATA)
@Path("/test-app")
public interface MultiPartClient extends AutoCloseable {

@POST
@Path("upload/")
void uploadFile(List<EntityPart> entityParts) throws IOException;
}
----

The example code utilizing this ingerface

source,java]
----
public void uploadMultipleFiles() throws Exception {
try (MultiPartClient client = RestClientBuilder.newBuilder()
.baseUri(uri)
.build(MultiPartClient.class)) {
final Map<String, byte[]> entityPartContent = new LinkedHashMap<>(2);
try (InputStream in = MultiPartClientTest.class
.getResourceAsStream("/multipart/test-file1.txt")) {
entityPartContent.put("test-file1.txt", in.readAllBytes());
}
try (InputStream in = MultiPartClientTest.class
.getResourceAsStream("/multipart/test-file2.txt")) {
entityPartContent.put("test-file2.txt", in.readAllBytes());
}
final List<EntityPart> files = entityPartContent.entrySet()
.stream()
.map((entry) -> {
try {
return EntityPart.withName(entry.getKey())
.fileName(entry.getKey())
.content(entry.getValue())
.mediaType(MediaType.APPLICATION_OCTET_STREAM_TYPE)
.build();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
})
.collect(Collectors.toList());
client.uploadFile(files);

}
}
----


== Send multipart/form-data parts from Jakarta Restful Web Services resources

Expand Down
2 changes: 1 addition & 1 deletion modules/reference/pages/diff/mp-61-70-diff.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ RestClientBuilder.newBuilder()

=== Processing multipart data

Information and example code are added to the xref:ROOT:send-receive-multipart-jaxrs.adoc#multipart[send and receive multipart/form-data parts in Jakarta Restful Web Services] for processing multipart data, introduced as part of RESTful Web Services version 3.1 in EE10.
The link:https://download.eclipse.org/microprofile/microprofile-rest-client-4.0/microprofile-rest-client-spec-4.0.html#_processing_multipart_data[MicroProfile Rest Client 4.0 specification] includes information and example code for processing multipart data, introduced as part of RESTful Web Services version 3.1 in EE10.


[#openapi]
Expand Down