-
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 Multipart @FormParam on EntityPart #41204
Open
ollelogdahl
wants to merge
7
commits into
quarkusio:main
Choose a base branch
from
ollelogdahl:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9ff8b79
Added test case for single @FormParam EntityPart
ollelogdahl 4690dc6
Added support for entity-parts
ollelogdahl 23541f2
Merge branch 'quarkusio:main' into main
ollelogdahl 8b80268
Access multipart body
ollelogdahl 370d18d
Merge branch 'main' into main
ollelogdahl ca0c91f
Improved EntityPart support
ollelogdahl dfc6638
Merge branch 'quarkusio:main' into main
ollelogdahl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
72 changes: 72 additions & 0 deletions
72
...er/runtime/src/main/java/org/jboss/resteasy/reactive/server/multipart/EntityPartImpl.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.jboss.resteasy.reactive.server.multipart; | ||
|
||
import java.io.*; | ||
import java.nio.charset.Charset; | ||
import java.util.Optional; | ||
|
||
import jakarta.ws.rs.WebApplicationException; | ||
import jakarta.ws.rs.core.*; | ||
|
||
import org.jboss.resteasy.reactive.common.util.UnmodifiableMultivaluedMap; | ||
|
||
public class EntityPartImpl implements EntityPart { | ||
private final String name; | ||
private final MultivaluedMap<String, String> headers; | ||
private final MediaType mediaType; | ||
private final String fileName; | ||
private final InputStream content; | ||
|
||
public EntityPartImpl(FormValue value, String controlName) { | ||
this.name = controlName; | ||
this.headers = new UnmodifiableMultivaluedMap(value.getHeaders()); | ||
this.mediaType = MediaType.valueOf(value.getHeaders().getFirst("Content-Type")); | ||
this.fileName = value.getFileName(); | ||
|
||
try { | ||
if (value.isFileItem()) { | ||
this.content = new FileInputStream(value.getFileItem().getFile().toFile()); | ||
} else { | ||
this.content = new ByteArrayInputStream(value.getValue().getBytes(Charset.defaultCharset())); | ||
} | ||
} catch (IOException e) { | ||
throw new MultipartPartReadingException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
@Override | ||
public Optional<String> getFileName() { | ||
return Optional.ofNullable(this.fileName); | ||
} | ||
|
||
@Override | ||
public InputStream getContent() { | ||
return this.content; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably lazily build the |
||
} | ||
|
||
@Override | ||
public <T> T getContent(Class<T> type) | ||
throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { | ||
ollelogdahl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return null; | ||
} | ||
|
||
@Override | ||
public <T> T getContent(GenericType<T> type) | ||
throws IllegalArgumentException, IllegalStateException, IOException, WebApplicationException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public MultivaluedMap<String, String> getHeaders() { | ||
return this.headers; | ||
} | ||
|
||
@Override | ||
public MediaType getMediaType() { | ||
return this.mediaType; | ||
} | ||
} |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what encoding the byte array should have, but I suspect not the default charset. First, because we prefer utf-8 everywhere, and second because it's possible that anybody reading the
InputStream
will use the part's encoding as set in headers or media type, which would be different to the default charset.Also, perhaps the
InputStream
should be build lazily ingetContent
? Otherwise if a user closes it, doing two calls togetContent
will fail.