2 years ago

#48114

test-img

Dhiraj Mehta

Send string encoded file as multipart in resttemplate spring boot java

I have an API that accepts multipart data. End users are iOS and Android users. Android users sends the zip file in encoded string format and iOS users sends the zip itself.

I want to convert encoded string sent by android users back to zip and send it to other spring micro service. How can I do this in Java?

When iOS send a zip file, I convert it to ByteArrayResource and after conversion, file looks like this in debugger

enter image description here

But when Android users sends the encoded string of a file, I convert it to ByteArrayResource and that file after conversion looks like this

enter image description here

Code I wrote to convert this file to ByteArrayResource is

new ByteArrayResource(Base64.getDecoder().decode(encodedFile))

How can I make above code compatible so that it is acceptable by multipart rest api.

Can anyone help me for the same. I have been banging my head on it for almost a week but no success yet.

Thanking in anticipation.

java

spring-boot

multipartform-data

resttemplate

multipart

0 Answers

Your Answer

Accepted video resources