I want to ask that how to send json with binary file attachment in jax-rs. I mean a java class producing the both. Can someone answer with an example ? Thanks for answering.
Asked
Active
Viewed 547 times
1 Answers
1
I see a couple options, both with some disadvantages.
You could...
Use multipart as the response type. You can see an example in this post. Also see Jersey Multipart Documentation. Note that not all clients support consuming multipart; some only support sending multipart data.
You could...
Base64 encode the file to a string and just add it as part of the JSON. One limitation of this is the entity size will be inflated. Base64 encoding will increase the size of the file.

Paul Samsotha
- 205,037
- 37
- 486
- 720
-
You made a good answer, if you liked the question feel free to upvote :) – Orkun Feb 08 '21 at 14:16