To overcome this request size limitation imposed by ASP.NET, chunked transfer-encoding must be used.
A chunked request does not include a content-length header for the whole request. A chunked file transfer is sent as a series of chunks, each preceded by its own size indicator. ASP.NET will not reject the large request because it contains no content-length header. The maxRequestLength setting in web.config will be ignored. With chunked-transfer encoding, no matter how large the upload request is, it will not be dropped by ASP.NET.
Since browsers currently do not support chunked transfer encoding, XFile needs to be used on the client, and chunked transfer encoding has to be turned on in the client-side script using the TransferEncoding property of the XFRequest object. The code snippet below sends the upload request to the server using XFile with chunked encoding turned on when the user clicks an HTML Button:
function UploadButton_OnClick()
{
/* "xFile" is the instance of the XFRequest object
* created in the <OBJECT> tag
*/
// Set the URL to which the upload will be posted
xFile.CurrentURL =
"http://[server_name]/XFile_Upload_App/FileUp_UploadProcess.uplx";
// Set Timeout for XFile (in seconds)
// Set to -1 so that XFile won't time out during the transfer
xFile.Timeout = -1;
// Turn on chunked transfer-encoding
xFile.TransferEncoding = 1;
// Set the files to be uploaded
xFile.AddFile("C:\\Temp\\uploadFile1.sa","FileName1");
xFile.AddFile("C:\\Temp\\uploadFile2.sa","FileName2");
// Begin the transfer
xFile.Start();
// Disable the upload button
document.all("UploadButton").disabled = true;
}
3-tier uploads with FileUpEE
Not only can FileUpEE handle unlimited sized uploads, it can also perform 3-tier uploads to a secure isolated fileserver.
Turning on chunked transfer encoding in XFileEE as seen in the code above assures that the “client-to-webserver” part of a three-tier upload transfer will be chunked. However, if you are doing a 3-tier upload, you will also need to configure the "webserver-to-fileserver" part of the transfer to handle over 2 GB.
For the “webserver-to-fileserver” part of the transfer, FileUpEE uses the HTTP layer to send a SOAP request to the fileserver, and this request is not “chunked” by default. Therefore ASP.NET will reject the request when it arrives on the fileserver due to the maxRequestLength limitation.
In order for FileUpEE to send a request over 2 GB to the fileserver in chunks, chunked transfer encoding needs to be set explicitly on FileUpEE using the set_TransferEncoding method in C# (or the TransferEncoding property in VB.NET) in the webserver processing page as shown in the code-snippet below:
[C#]
|
[VB.NET]
|
|
public void processUploadOnWebServer()
{
// Instantiate the FileUpEE object
FileUpEe oFileUpEe = new FileUpEe();
// Set the TransferStage to saWebServer
oFileUpEe.TransferStage = saTransferStage.saWebServer;
// Turn on chunked transfer-encoding on the WebServer stage
oFileUpEe.set_TransferEncoding(saTransferStage.saWebServer,
saTransferEncoding.saChunked);
// Set the URL of the fileserver script
oFileUpEe.TargetUrl =
"http://[server_name]/FileServer/FileUpEE_FileServerProcess.uplx";
// Set the directory path on the fileserver to which the uploaded files
// will be saved
oFileUpEe.DestinationDirectory =
"[Drive_Letter]:\\[Destination_Directory_Path]";
// Process the Request data sent from the client
oFileUpEe.ProcessRequest(Request, false, false);
// Send the HTTP request to the fileserver
saResult result = oFileUpEe.SendRequest();
....
}
Public Sub processUploadOnWebServer()
'--- Instantiate the FileUpEE object
Dim oFileUpEe As FileUpEe = New FileUpEe()
'--- Set the TransferStage to saWebServer
oFileUpEe.TransferStage = saTransferStage.saWebServer
'--- Turn on chunked transfer-encoding on the WebServer stage
oFileUpEe.TransferEncoding(saTransferStage.saWebServer) =
saTransferEncoding.saChunked
'--- Set the URL of the fileserver script
oFileUpEe.TargetUrl =
"http://[server_name]/FileServer/FileUpEE_FileServerProcess.uplx"
'--- Set the directory path on the fileserver to which the uploaded files
'--- will be saved
oFileUpEe.DestinationDirectory =
"[Drive_Letter]:\[Destination_Directory_Path]"
'--- Process the Request data sent from the client
oFileUpEe.ProcessRequest(Request, False, False)
'--- Send the HTTP request to the fileserver
Dim result As saResult = oFileUpEe.SendRequest()
....
End Sub
|
Note: There was a known issue in certain versions of FileUpEE with turning on chunked transfer encoding on the webserver. This issue has been addressed and fixed in a pre-release build of FileUpEE. For more information, see this KB article:
Three-tier chunked uploads with FileUpEE do not work properly
|