Reputation: 49
I need to convert MultipartFile received from client to bytes array to send it to another server(without saving file on first server). I wanted to use MultipartFile.getBytes() function, by it's converting it to something like [B@71336b2e . I'm getting file from request
@RequestMapping(method = RequestMethod.POST)
public Object doPost(ModelMap model, HttpServletRequest request, HttpServletResponse response,
@RequestParam(value = "imageFile", required = false) MultipartFile file) {
and then setter
fbImg.setFile(file.getBytes());
Then I wanted to send it to other server in JSON with rest of data, and convert it to BufferedImage. Is there some other method to convert MultipartFile to bytes array, or am I oding something wrong? Or is there simpler method to send images between servers without saving them?
Upvotes: 0
Views: 5762
Reputation: 23
'[B@71336b2e' is a toString() output of byte[]. if you want real file convert it into base64 or change it into file and content type
Upvotes: 0