Spring showcase with image from camera.
Hi There,
I am trying to modify the example "HttpPostFormDataActivity" to use an image taken from the camera rather than an image loaded from the <code>Resource resource = new ClassPathResource("res/drawable/spring09_logo.png");</code>
I have got it all hanging together except one critcal part:
For
Code:
formData.add("file", resource);
I had tried :
Code:
ByteArrayOutputStream bos = new ByteArrayOutputStream();
photo.compress(CompressFormat.PNG, 0 /*ignored for PNG*/, bos);
byte[] bitmapdata = bos.toByteArray();
resource = new ByteArrayResource(bitmapdata);
formData.add("file", resource);
What must resource now be in order for it to be accepted by the Server:
Code:
@RequestMapping(value = "postformdata", method=RequestMethod.POST, headers="Content-Type=multipart/form-data")
public @ResponseBody String handleFormUpload(@RequestParam("description") String description, @RequestParam("file") MultipartFile file) {
I was going to go down the route or creating a temp file with the image just taken and use the same code? Is the a correct approach.
Any help / guidance would be appreciated.