1

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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

You made a good answer, if you liked the question feel free to upvote :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.