-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Support programmatic multipart/form-data
responses
#28631
Labels
Milestone
Comments
Can you show an example use of RESTEasy Classic's Thanks |
The Kotlin code we have which uses this API looks like this: fun toMultipartFormDataOutput(): MultipartFormDataOutput = MultipartFormDataOutput().apply {
for ((key, result) in results) {
val part = addFormData(key, result.content, result.mediaType)
result.pageCount?.let {
part.headers[Param.CONTENT_RANGE] = listOf("pages 0-${it - 1}/$it")
part.headers["x-page-count"] = listOf(it)
}
}
} |
/cc @FroMage, @stuartwdouglas |
cc @Sgitario who did the multipart output stuff in RR |
Sgitario
added a commit
to Sgitario/quarkus
that referenced
this issue
Oct 25, 2022
With these changes, users can also manually append the parts of the form using the class `MultipartFormDataOutput` as: ```java import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jboss.resteasy.reactive.server.core.multipart.MultipartFormDataOutput; @path("multipart") public class Endpoint { @get @produces(MediaType.MULTIPART_FORM_DATA) @path("file") public MultipartFormDataOutput getFile() { MultipartFormDataOutput form = new MultipartFormDataOutput(); form.addFormData("person", new Person("John"), MediaType.APPLICATION_JSON_TYPE); form.addFormData("status", "a status", MediaType.TEXT_PLAIN_TYPE) .getHeaders().putSingle("extra-header", "extra-value"); return form; } } ``` Fix quarkusio#28631 This last approach allows you adding extra headers to the output part.
Sgitario
added a commit
to Sgitario/quarkus
that referenced
this issue
Oct 26, 2022
With these changes, users can also manually append the parts of the form using the class `MultipartFormDataOutput` as: ```java import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jboss.resteasy.reactive.server.core.multipart.MultipartFormDataOutput; @path("multipart") public class Endpoint { @get @produces(MediaType.MULTIPART_FORM_DATA) @path("file") public MultipartFormDataOutput getFile() { MultipartFormDataOutput form = new MultipartFormDataOutput(); form.addFormData("person", new Person("John"), MediaType.APPLICATION_JSON_TYPE); form.addFormData("status", "a status", MediaType.TEXT_PLAIN_TYPE) .getHeaders().putSingle("extra-header", "extra-value"); return form; } } ``` Fix quarkusio#28631 This last approach allows you adding extra headers to the output part.
tmihalac
pushed a commit
to tmihalac/quarkus
that referenced
this issue
Oct 27, 2022
With these changes, users can also manually append the parts of the form using the class `MultipartFormDataOutput` as: ```java import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jboss.resteasy.reactive.server.core.multipart.MultipartFormDataOutput; @path("multipart") public class Endpoint { @get @produces(MediaType.MULTIPART_FORM_DATA) @path("file") public MultipartFormDataOutput getFile() { MultipartFormDataOutput form = new MultipartFormDataOutput(); form.addFormData("person", new Person("John"), MediaType.APPLICATION_JSON_TYPE); form.addFormData("status", "a status", MediaType.TEXT_PLAIN_TYPE) .getHeaders().putSingle("extra-header", "extra-value"); return form; } } ``` Fix quarkusio#28631 This last approach allows you adding extra headers to the output part.
gsmet
pushed a commit
to gsmet/quarkus
that referenced
this issue
Oct 31, 2022
With these changes, users can also manually append the parts of the form using the class `MultipartFormDataOutput` as: ```java import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jboss.resteasy.reactive.server.core.multipart.MultipartFormDataOutput; @path("multipart") public class Endpoint { @get @produces(MediaType.MULTIPART_FORM_DATA) @path("file") public MultipartFormDataOutput getFile() { MultipartFormDataOutput form = new MultipartFormDataOutput(); form.addFormData("person", new Person("John"), MediaType.APPLICATION_JSON_TYPE); form.addFormData("status", "a status", MediaType.TEXT_PLAIN_TYPE) .getHeaders().putSingle("extra-header", "extra-value"); return form; } } ``` Fix quarkusio#28631 This last approach allows you adding extra headers to the output part. (cherry picked from commit 6967fbc)
gsmet
pushed a commit
to gsmet/quarkus
that referenced
this issue
Oct 31, 2022
With these changes, users can also manually append the parts of the form using the class `MultipartFormDataOutput` as: ```java import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jboss.resteasy.reactive.server.core.multipart.MultipartFormDataOutput; @path("multipart") public class Endpoint { @get @produces(MediaType.MULTIPART_FORM_DATA) @path("file") public MultipartFormDataOutput getFile() { MultipartFormDataOutput form = new MultipartFormDataOutput(); form.addFormData("person", new Person("John"), MediaType.APPLICATION_JSON_TYPE); form.addFormData("status", "a status", MediaType.TEXT_PLAIN_TYPE) .getHeaders().putSingle("extra-header", "extra-value"); return form; } } ``` Fix quarkusio#28631 This last approach allows you adding extra headers to the output part. (cherry picked from commit 6967fbc)
zakkak
pushed a commit
to zakkak/quarkus
that referenced
this issue
Nov 15, 2022
With these changes, users can also manually append the parts of the form using the class `MultipartFormDataOutput` as: ```java import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jboss.resteasy.reactive.server.core.multipart.MultipartFormDataOutput; @path("multipart") public class Endpoint { @get @produces(MediaType.MULTIPART_FORM_DATA) @path("file") public MultipartFormDataOutput getFile() { MultipartFormDataOutput form = new MultipartFormDataOutput(); form.addFormData("person", new Person("John"), MediaType.APPLICATION_JSON_TYPE); form.addFormData("status", "a status", MediaType.TEXT_PLAIN_TYPE) .getHeaders().putSingle("extra-header", "extra-value"); return form; } } ``` Fix quarkusio#28631 This last approach allows you adding extra headers to the output part. (cherry picked from commit 6967fbc)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
With RESTEasy Classic there is the MultipartFormDataOutput API which allows programmatic creation of
multipart/form-data
responses, when the actual parts need to be created dynamically. In RESTEasy Reactive there is no such counterpart and I could not find any easy way to do this without basically implementing everything from scratch.Also note the OutputPart#getHeaders() API which would allow to programmatically add additional headers to the individual parts. This currently isn't possible with
org.jboss.resteasy.reactive.server.core.multipart.PartItem
.Implementation ideas
No response
The text was updated successfully, but these errors were encountered: