Reputation: 860
One way of doing is to convert the binary data to Base64 and send it along with meta data as MediaType.APPLICATION_JSON
.
The problem with this is client has to convert the binary data into Base64 before sending.
I also tried sending using MediaType.APPLICATION_OCTET_STREAM
format through REST. This works fine for binary data only.
One option is to send meta data in headers while using MediaType.APPLICATION_OCTET_STREAM
.
Is there any better way?
Thanks
Upvotes: 2
Views: 4398
Reputation: 208994
Use multipart/form-data
. This is what it's meant for. Not sure which Jersey version you are using, but here is the link for the Jersey 2.x documentation for Multipart support. Here's for 1.x (not really much information). You will need to do some searching for using multipart with Javascript clients (there is a bunch of information out there)
Upvotes: 2