forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RESTEasy Reactive - Support text/binary conversion for multipart files
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") 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
- Loading branch information
Showing
4 changed files
with
173 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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