I have a webapp that allows users to upload video files. These files vary in size, but some may be as large as 4GB.
The problem is that when a user submits a create/edit form that posts a large video file, there is an absurd amount of server-side processing that seems to take place before a response is given to the client. Sometimes this results in page timeouts.
Debugging this further, the majority of the time spent in limbo occurs AFTER the upload has complete, but BEFORE any code in the controller gets executed. I can see that the upload reaches 100% (either through the browser status bar or subscribing to XHR onprogress in my JS), and then absolutely nothing happens in my server logs for several minutes. Then, finally, my before hooks run, my action runs, etc.
So can anyone tell me what the heck is happening during this time? I'm assuming some sort of file copy, maybe from one temp directory to another, before I actually have access to the posted file in order to move it to its final destination?
I would think this would be a very common problem for anyone trying to handle large file uploads, but so far have come up with no answers.
Once the code in my action actually runs, then I can handle queueing the final file move (final destination is on NAS) by using delayed_job or something similar, but I have no clue what to do about the period of time spent in limbo.
Ideally it would be awesome if as the upload progresses, the file chunks received are sent straight over to their final destination on the NAS to avoid repetitive file copies, but I have absolutely no idea how to possibly make that happen or if that level of control is even possible through rails.