multipartform data - How to handle FineUploader POST request in Java in PlayFramework? -


i trying integrate fineuploader in play framework code. view part set , working fine.

i not clear how retrieve file in controllers upload method. , other query parameters, qquuid, qqfilename, content-type e.tc.

following dump of file upload request sent fileuploader:-

request headers  accept:application/json accept-encoding:gzip, deflate accept-language:en-us,en;q=0.8 cache-control:no-cache connection:keep-alive content-length:1021645 content-type:multipart/form-data; boundary=----webkitformboundaryk8bzisbkkjjqiwq6 dnt:1 host:localhost:9000 origin:http://localhost:9000 referer:http://localhost:9000/computers user-agent:mozilla/5.0 (macintosh; intel mac os x 10_9_4) applewebkit/537.36 (khtml, gecko) chrome/42.0.2311.152 safari/537.36 x-requested-with:xmlhttprequest  request payload ------webkitformboundaryk8bzisbkkjjqiwq6 content-disposition: form-data; name="id"  593 ------webkitformboundaryk8bzisbkkjjqiwq6 content-disposition: form-data; name="qquuid"  bafb6448-1a87-40cc-abae-9624f37131cc ------webkitformboundaryk8bzisbkkjjqiwq6 content-disposition: form-data; name="qqfilename"  test.png ------webkitformboundaryk8bzisbkkjjqiwq6 content-disposition: form-data; name="qqtotalfilesize"  1020995 ------webkitformboundaryk8bzisbkkjjqiwq6 content-disposition: form-data; name="qqfile"; filename="test.png" content-type: image/png   ------webkitformboundaryk8bzisbkkjjqiwq6-- 

i found out exploring play apis, sample code below.

    http.multipartformdata body = request().body().asmultipartformdata();     http.multipartformdata.filepart uploadfilepart = body.getfile("qqfile");      string filename = uploadfilepart.getfilename();     file file = uploadfilepart.getfile();        map<string,string[]> datapart = request().body().asmultipartformdata().asformurlencoded();      iterator = datapart.entryset().iterator();     while (it.hasnext()) {         map.entry pair = (map.entry)it.next();         string[] values  = (string[]) pair.getvalue();         system.out.println(pair.getkey() + " = " + values[0]);     } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -