We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Glassfish 7.0M6, Java 17, Windows 10.
I used the following client codes to upload files,
List<EntityPart> parts = List.of( EntityPart.withName("textFile").fileName("test.txt") .content(this.getClass().getResourceAsStream("/test.txt")) .mediaType(MediaType.TEXT_PLAIN_TYPE) .build(), EntityPart.withName("imageFile").fileName("test.svg") .content(this.getClass().getResourceAsStream("/test.svg")) .mediaType(MediaType.APPLICATION_SVG_XML_TYPE) .build() ); var genericEntity = new GenericEntity<List<EntityPart>>(parts) { }; var entity = Entity.entity(genericEntity, MediaType.MULTIPART_FORM_DATA); Response r = target.request().post(entity);
The server side codes are like this.
@Path("list") @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public Response uploadMultiFiles(List<EntityPart> parts) { LOGGER.log(Level.INFO, "Uploading files: {0}", parts.size()); parts.forEach( part -> { LOGGER.log( Level.INFO, "{0},{1},{2},{3}", new Object[]{ part.getMediaType(), part.getName(), part.getFileName(), part.getHeaders() } ); try { copy(part.getContent(), Paths.get(uploadedPath.toString(), part.getFileName().get()), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { throw new RuntimeException(e); } } ); return Response.ok().build(); }
Running the client in tests, in the Glassfish server.log, all mediatypes are changed to application/octet-stream.
application/octet-stream
[2022-07-16T23:28:38.775+0800] [glassfish 7.0] [INFO] [] [com.example.MultipartResource] [tid: _ThreadID=41 _ThreadName=http-listener-1(4)] [timeMillis: 1657985318775] [levelValue: 800] [[ Uploading files: 2]] [2022-07-16T23:28:38.778+0800] [glassfish 7.0] [INFO] [] [com.example.MultipartResource] [tid: _ThreadID=41 _ThreadName=http-listener-1(4)] [timeMillis: 1657985318778] [levelValue: 800] [[ application/octet-stream,textFile,Optional[test.txt],{Content-Type=[application/octet-stream], Content-Disposition=[form-data; filename="test.txt"; name="textFile"]}]] [2022-07-16T23:28:38.787+0800] [glassfish 7.0] [INFO] [] [com.example.MultipartResource] [tid: _ThreadID=41 _ThreadName=http-listener-1(4)] [timeMillis: 1657985318787] [levelValue: 800] [[ application/octet-stream,imageFile,Optional[test.svg],{Content-Type=[application/octet-stream], Content-Disposition=[form-data; filename="test.svg"; name="imageFile"]}]]
The example project to produce the issue: https://github.com/hantsy/jakartaee10-sandbox/tree/master/rest
The text was updated successfully, but these errors were encountered:
Yes, this is a bug. Thank you!
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Glassfish 7.0M6, Java 17, Windows 10.
I used the following client codes to upload files,
The server side codes are like this.
Running the client in tests, in the Glassfish server.log, all mediatypes are changed to
application/octet-stream
.The example project to produce the issue: https://github.com/hantsy/jakartaee10-sandbox/tree/master/rest
The text was updated successfully, but these errors were encountered: