I tried to receive files through restayl, but received only MULTIPART_FORM_DATA. How can I extract my file?
I found several blocks of code, but their types are not available ... RESTlet: how to handle requests for multipart / form-data?
DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(1000240); // 2/ Create a new file upload handler RestletFileUpload upload = new RestletFileUpload(factory);
My current code is:
@Put public void handleUpload(Representation entity) { if (entity !=null) { if (MediaType.MULTIPART_FORM_DATA.equals(entity.getMediaType(), true)) { Request restletRequest = getRequest(); Response restletResponse = getResponse(); HttpServletRequest servletRequest = ServletUtils.getRequest(restletRequest); HttpServletResponse servletResponse = ServletUtils.getResponse(restletResponse); try { Upload2(restletRequest, entity); } catch (IOException e) {
After saving with this method, I have something like this, and I only want to save the contents with the name "picture":
z------WebKitFormBoundarysOvzWKPqyqW7DiTu Content-Disposition: form-data; name="picture"; filename="_MG_4369.jpg" Content-Type: image/jpeg *ExifII*
How far have I read parsing data in multipart form is not yet supported? But there must be a solution for sending files via restlet
I tried the rest of the calls through the chrome postman. Only support for multiple files is supported. Possible solution for sending an image as raw text?
source share