0

I am using play framework v2.4 and am testing file uploads sent via a web form (xhr call via angular). I have tried the following two options in the play framework controller (based on https://www.playframework.com/documentation/2.4.x/JavaFileUpload) but neither option works (I also added the curl sample I tried but I am unable to get a reference to the file - its always null). The MultipartFormData/File is null in either case.
Thanks

MultipartFormData body = request().body().asMultipartFormData();

or

File file = request().body().asRaw().asFile();

The curl command I am using is as follows (I can see the file data being sent from curl):

curl -v --cookie "Auth-Token=dc6eb764-4436-4571-b4bf-8cf5dg36b71b" -F "doc=@/home/test/docs/books/play2.pdf" https://local.test.com/a/api/contact/abc/test
ali haider
  • 19,175
  • 17
  • 80
  • 149
  • issue was with the client upload in JS - the file was never making it to the server. Fixing the curl command allowed me to test the file upload on the server – ali haider Nov 13 '15 at 20:43
  • Ali, could you perhaps post how you debugged it as part of an answer to your own question (rather than just a comment)? – wwkudu Nov 15 '15 at 01:42

1 Answers1

0

the issue was with the client side JS code that was not uploading the file. The following worked:

MultipartFormData body = request().body().asMultipartFormData();

test with curl

curl -v --cookie "Auth-Token=dc6eb764-4436-4571-b4bf-8cf5dg36b71b" -F "doc=@/home/test/docs/books/play2.pdf" https://local.test.com/a/api/contact/abc/test
ali haider
  • 19,175
  • 17
  • 80
  • 149