I'll check this one. 

-- 
Weinan Li
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Thursday, January 24, 2013 at 11:29 AM, Gabriella Turek wrote:

> > My form POJO:
> > 
> >     public class FileUploadForm { 
> >   
> >   
> >       @FormParam("file")
> >       @PartType(MediaType.APPLICATION_OCTET_STREAM)
> >       private byte[] data;
> >   
> >       @FormParam("user")
> >       @PartType(MediaType.TEXT_PLAIN)
> >       private String user;
> >   
> >       @FormParam("password")
> >       @PartType(MediaType.TEXT_PLAIN)
> >       private String password;
> >   
> >       @FormParam("filename")
> >       @PartType(MediaType.TEXT_PLAIN)
> >       private String filename;
> > 
> >       public FileUploadForm() {} 
> > 
> >       public byte[] getData() { 
> >        return data;
> >       }
> > 
> >       public void setData(final byte[] data) { 
> >           this.data = data;
> >       }
> > 
> >       public String getUser() { 
> >         return user;
> >       }
> > 
> >       public void setUser(String user) { 
> >         this.user = user;
> >       }
> > 
> >       public String getPassword() { 
> >         return password;
> >       }
> > 
> >       public void setPassword(String password) { 
> >         this.password = password;
> >       }
> > 
> >        public String getFilename() { 
> >         return filename;
> >       }
> > 
> >       public void setFilename(String filename) { 
> >         this.filename = filename;
> >       }
> > 
> >     }  
> > 
> > My service side method definition: 
> > 
> >     @POST 
> >     @Path("/upload")
> >     @Consumes("multipart/form-data")
> >     @Produces(MediaType.TEXT_PLAIN)
> >     public Response upload(@MultipartForm FileUploadForm form);
> > 
> I tried this: 
> 
> 
>     MockHttpRequest request = MockHttpRequest.post("/upload");
> 
> 
>     request.contentType(MediaType.MULTIPART_FORM_DATA_TYPE);
> 
> 
>     FileUploadForm upload = new FileUploadForm();
> 
> 
>     upload.setUser(USER);
> 
> 
>     upload.setPassword(PASSWORD);
> 
> 
>     upload.setFilename("file.zip");
> 
> 
>     String fileToUpload = "testdata/file.zip";
> 
> 
>     FileInputStream fis = new FileInputStream(fileToUpload);
> 
> 
>     byte[] fileData = IOUtils.toByteArray(fis);
> 
> 
>     upload.setData(fileData);
> 
> 
>     request.content(upload.toString().getBytes());
> 
> 
>     MockHttpResponse response = new MockHttpResponse();
> 
> 
>     dispatcher.invoke(request, response);
> 
> 
>     assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> But I get 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 2013-01-24 16:25:14,903: WARN  
> [org.jboss.resteasy.core.SynchronousDispatcher](?:?)  - Failed executing POST 
> /upload
> 
> 
> org.jboss.resteasy.spi.ReaderException: java.io.IOException: Unable to get 
> boundary for multipart
> 
> 
> 
> 
> 
> 
> Thanx
> 
> 
> Gaby
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> Please consider the environment before printing this email.
> NIWA is the trading name of the National Institute of Water & Atmospheric 
> Research Ltd. 
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> 
> _______________________________________________
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net 
> (mailto:Resteasy-users@lists.sourceforge.net)
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
> 
> 


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to