3 Replies Latest reply on Jul 14, 2011 3:17 AM by Jean-Frederic Clere

    How does RESTEasy client framework handles file upload attribute

    james tang Newbie

      I am writing a java client file upload method using RESTEasy client framework to talk to Grails service via HTTP.

      Here is some code lines from the java client:


      MultipartFormDataOutput form = new MultipartFormDataOutput();

      form.addFormData("ipAddress", “”, MediaType.TEXT_PLAIN_WITH_CHARSET_US_ASCII_TYPE);

      form.addFormData("file", new java.io.File("file.csv"), MediaType.valueOf("application/octet-stream; charset=ISO-8859-1"));



      The “proxy” is created from an interface method like this:






              public UploadCSVResponse uploadCSV(MultipartFormDataOutput uploadStoreCSVForm);


      When the statement "proxy.uploadCSV(form);" is executed, I saw the HTTP request message like this:


              Content-Disposition: form-data; name="file"

              Content-Type: application/octet-stream;charset="ISO-8859-1"

              Content-Length: 1000


              *** the csv file contents ***


      On the Grails service side, it requires the "filename" attribute in the "Content-Disposition" line.

      It is expecting:


              Content-Disposition: form-data; name="file";  filename="file.csv"


      I Googled it for the whole day. I was not able to find a solution in the RESTEasy client code.

      I am also not allowed to change the Grails service code.


      Are there any RESTEasy developers can tell me how to insert this {filename="file.csv"} into my RESTEasy client code above?


      Thanks a lot for your help.