Attachment/UploadChunk on a server farm

posted Mar 24, 2016, 6:02 AM by Eric Patrick   [ updated Apr 6, 2016, 5:39 AM ]
The Attachment/UploadChunk method supports efficient upload of files using HTML5 features. In a load-balanced server farm without sticky sessions, this method must ensure that chunks of a file received by different servers are appended to the same physical file. To ensure this, the UploadChunk method must leverage a FileObject that implements an Append method. As of the time of this post, the only standard FileObject that supports Append is UNCFile.

UploadChunk will work as follows:
  • if the application setting ScratchpadFileObject is not empty, then a file object matching ScratchpadFileObject will be used
  • otherwise, the first UNCFile-based FileObject will be used
Once all the chunks have been appended to the scratchpad file, the application will call Attachment/Queue/MoveFile to move the file from the scratchpad to a 'final' repository (typically S3). Note that we queue this move, instead of executing it, so the user does not need to wait for a large files to be moved between repositories. A very large file move may result in an HTTP timeout.

If the file is accessed before the move happens, it is simply read from the scratchpad file object, as opposed to the 'final' repository.