1

I have the following code. I am wondering when the file upload will happen. I have a large file like 200MB. will it be in model when the second line executes?

play.mvc.Http.MultipartFormData body = request().body().asMultipartFormData();
play.mvc.Http.MultipartFormData.FilePart model = body.getFile("modelData");
Niamath
  • 309
  • 4
  • 12
  • Might have some luck with using a debugger for this answer. As I understand it, you're asking if the 2nd line is going to run prior to the 1st line finishing. Best bet is to try it in a debugger and see what happens. – Patrick J Abare II May 22 '14 at 19:04
  • actually I want to know when the file is uploaded to server physically available? as soon as the second line executes or it will take some time after the execution of 2nd line.(file size 200MB) – Niamath May 22 '14 at 19:11

1 Answers1

2

Assuming this is in a controller method, The file will have being uploaded before your first line (and stored in a temp file by the server).

So the answer is yes it will be available to the model (at either the first or second lines).

It's possible to stream the file, refer to this for more info Uploading file as stream in play framework 2.0

Community
  • 1
  • 1
stringy05
  • 6,511
  • 32
  • 38
  • it will be synchronous? – Niamath May 23 '14 at 16:10
  • the current implementation is synchronous in terms of the request with the file payload. You can stream it as per the link in the answer, which is still synchronous, but the advantage is that the server wont create a temporary file, so you can do whatever you want with the file while its in memory. – stringy05 May 26 '14 at 00:48