Forum Discussion

liki7411's avatar
Occasional Contributor
3 years ago

Sent jpg as byte array

I want to send an image which is in local file as byte array.


I am trying to post an image -(jpg format)  with the request , 

I have tried the media type as - mixed/form-data/ and url-encoded too, but i see the tool trying to post as base64 as below,


<img src="data&colon;image/jpeg;base64,/9j/..values..../2Q==" alt=""/>.


  • Also i have written groovy script to convert from base64 to byte array.Let me know if its incorrect.
  • import
    import java.util.*
    //import org.apache.commons.codec.binary.Base64

    byte[] fileContent = FileUtils.readFileToByteArray(new File('C:/Users/likith.n/Documents/Test.jpg'));
    String encodedString = Base64.getEncoder().encodeToString(fileContent);
    return encodedString

Also please let me know how to send it in byte array and mention the media type to send.

No RepliesBe the first to reply