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
RESTEasy Reactive - Support text/binary conversion for multipart files #27498
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
geoand
reviewed
Aug 25, 2022
...me/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
Assuming we receive the following request: ``` Content-Disposition: form-data; name="textPart"; filename="my_file.txt" Content-Type: application/octet-stream Content-Transfer-Encoding: binary ``` We can load the content of the file using the `FileUpload` class: ```java public class FormData { @FormParam("myFile") public FileUpload myFile; } ``` However, according to what the specs state: ``` The presence of the filename parameter does not force an implementation to write the entity to a separate file. It is perfectly acceptable for implementations to leave the entity as part of the normal mail stream unless the user requests otherwise. As a consequence, the parameter may be used on any MIME entity, even `inline' ones. These will not normally be written to files, but the parameter could be used to provide a filename if the receiving user should choose to write the part to a file. ``` Then, we should not enforce the use of `FileUpload` and hence also support reading the whole content of the file into strings, and other binary formats like byte[] and InputStream. ```java public class FormData { @FormParam("myFile") @PartType(MediaType.APPLICATION_OCTET_STREAM) public String myFile; } public class FormData { @FormParam("myFile") @PartType(MediaType.APPLICATION_OCTET_STREAM) public byte[] binaryPart; } public class FormData { @FormParam("myFile") @PartType(MediaType.APPLICATION_OCTET_STREAM) public InputStream streamPart; } ``` Fix quarkusio#27083
geoand
approved these changes
Aug 26, 2022
geoand
added
the
triage/waiting-for-ci
Ready to merge when CI successfully finishes
label
Aug 26, 2022
quarkus-bot
bot
added
kind/bugfix
and removed
triage/waiting-for-ci
Ready to merge when CI successfully finishes
labels
Aug 26, 2022
FroMage
added a commit
to FroMage/quarkus
that referenced
this pull request
Aug 26, 2022
FroMage
added a commit
to FroMage/quarkus
that referenced
this pull request
Oct 4, 2022
FroMage
added a commit
to FroMage/quarkus
that referenced
this pull request
Oct 10, 2022
FroMage
added a commit
to FroMage/quarkus
that referenced
this pull request
Oct 11, 2022
FroMage
added a commit
to FroMage/quarkus
that referenced
this pull request
Oct 17, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Assuming we receive the following request:
We can load the content of the file using the
FileUpload
class:However, according to what the specs state:
Then, we should not enforce the use of
FileUpload
and hence also support reading the whole content of the file into strings, and other binary formats like byte[] and InputStream.Fix #27083