pI am using a plupload (plupload.com) jQuery plugin to AJAX a image file to a Java Spring server. I have tried different implementations of the server side RESTful Controller Endpoint. I have attached the specific method which handles the file upload url. Any help will be very appreciated. Thank you.
@RequestMapping(value = "/pictureUpload", method = RequestMethod.POST )
public @ResponseBody
String productPictureUploadPost(@RequestBody MultipartFile multipartFile) {
HomeController.logger.info("In method productPictureUploadPost in SettingsPanelController. : Entering");
String orgName = multipartFile.getOriginalFilename();
String filePath = "/my_uploads/" + orgName;
File dest = new File(filePath);
try {
multipartFile.transferTo(dest);
} catch (IllegalStateException e) {
e.printStackTrace();
return "File uploaded failed:" + orgName;
} catch (IOException e) {
e.printStackTrace();
return "File uploaded failed:" + orgName;
}
HomeController.logger.info("In method productPictureUploadPost in SettingsPanelController. Exiting : " + "File uploaded:" + orgName);
return "File uploaded:" + orgName;
}
Also I have attached the servlet .xml multipart resolver declaration.
<bean class="org.springframework.web.multipart.support.StandardServletMultipartResolver"/>
On the client side I have the plugin file called as I have attached below.
$(document).ready(function() {
$("#uploader").plupload({
// General settings
runtimes: 'html5,flash,silverlight,html4',
url: "/pictureUpload",
// Maximum file size
max_file_size: '1000mb',
// User can upload no more then 20 files in one go (sets multiple_queues to false)
max_file_count: 3,
// Specify what files to browse for
filters: [
{ title: "Image files", extensions: "jpg,jpeg,gif,png" }
],
// Rename files by clicking on their titles
rename: true,
// Sort files
sortable: true,
// Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
dragdrop: true,
// Views to activate
views: {
list: true,
thumbs: true, // Show thumbs
active: 'thumbs'
},
// Flash settings
flash_swf_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/flash/Moxie.cdn.swf',
// Silverlight settings
silverlight_xap_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/silverlight/Moxie.cdn.xap'
});
});