Upload large files
Generally, HTTP protocol does not handle more requests data than 2GB. Client, such as a browser, may not be able to send more data than 2GB, because, in general web server don't receive more 2GB requests.
DEXTUpload.NET Professional provides a function capable of processing large size data using DEXTUploadNX (PlugIN base) and DEXTUpload such as X5 in (HTML5 base), their component products together. (Uploading of large files, is possible only when the integration with components, not alone.)
Upload of large files is different to be processing from the upload of the general file. In general, the data sent from the client such as a browser, the elements of the plurality of files are transmitted with a plurality of form elements(string) together. This request is processed at one time with the "FileUpload" class. However, uploading of large files, does not contain all the elements(strings and files) to a single request by the client, to transfer only a single file. In a nutshell, if we want to send the 10 files, all files are sent on one request in the general upload of the file. But in the upload of large files, are sent 10 times of the request. The reason for sending individually division denominated the request of the upload of large files is because can not handle larger than 2GB on HTTP, in order to process the large files, the client sends divided the request for a number of file. Further, since the size of each file exists in the case of more than 2GB, it is necessary to send the file also partially split.
For example assuming the number of files is 10 and the each size of a file is 2.5GB. If each request is available to contain data about 500MB, the 50(2.5 / 0.5 * 10 = 50) requests approximately occur totally.
Using the DEXTUpload.NET Professional product, in the case of processing the upload of large files, there is no need to create a server-side code you need to process all the requests of 50 times, and the DEXTUpload.NET Professional product guarantees that you can get only one file per one request. so you can code for processing the upload of requests as many as the number(10 times) of files.
The DEXTUpload.NET Professional product has no settings to distinguish between general and large. In the perspective of developers, rather than processing a large number of files in the code that handles the upload, it is only the difference of writing code to handle only one file at a time.
For more information about the upload of large files, it will be described with the DEXTUploadX5 products. (DEXTUploadX5 product certification process refers to the DEXTUploadX5 manual.)
- DEXTUploadX5 + ASP.NET
-
function onDX5Created(id) { var dx = dx5.get(id); // Sets the path to process the file upload. dx.setUploadURL("http://../upload.ashx?use=dext"); // Sets to "EXNJ" to use the large file upload method. dx.setUploadMode("EXNJ"); // Sets the block size in bytes to divide files. dx.setUploadBlockSize(10 * 1024 * 1024); }
The DEXTUploadX5 plays the role of a "sender" to send the file. On the other hand, the DEXTUpload.NET Professional plays the role of a "receiver" to receive the file on the server side.
The DEXTUploadX5 use the "setUploadURL" function to set the path(address) to process the upload without requesting a multipart data by using the "form" element.
If the path in the processing of uploaded has no "use=dext" query string, then the DEXTUpload.NET Professional product is not working and so it cannot process the upload of large files. Therefore, to make sure to specify the "use=dext" query string.
Upload of files using the DEXTUploadX5 is, because it does not require a response data in HTML format, the code that handles the upload of files, it is recommended that you use the ashx general handler than aspx page.
The code of server-side is as follows.
public class upload : IHttpHandler { public void ProcessRequest(HttpContext context) { Upload(context); } } private void Upload(HttpContext context) { using (var dext = new FileUpload()) { // Large files only process one file at a time. // If you upload 50 files, the handler's "ProcessRequest" method is called a total of 50 times. var element = dext.GetSingleFileElement(); if (!element.IsEmpty) { // Saves the uploaded file. element.Save(); ... } else { // If the file does not exist, IsEmpty Properties is "true". ... } } }
The DEXTUploadX5 is not forwarding an empty file.
Therefore, "IsEmpty" property must always be "false". Otherwise, it should be noted that current request is not sent by the DEXTUploadX5.
- DEXTUploadX5 + ASP.NET MVC
-
function onDX5Created(id) { var dx = dx5.get(id); // Sets the path to process the file upload. dx.setUploadURL("http://../Sample/Upload?use=dext"); // Sets to "EXNJ" to use the large file upload method. dx.setUploadMode("EXNJ"); // Sets the block size in bytes to divide files. dx.setUploadBlockSize(10 * 1024 * 1024); }
Upload of files using the DEXTUploadX5 is, because it does not require a response data in HTML format, it should be using the "Controller.Content" method to return the object of "ContentResult" class in the method that will handle the upload of the file.
Code of server-side is as follows.
[UseDEXT] public ActionResult Upload([Bind(Prefix = "DEXTUploadX5_FileData")] DEXTPostedFile file) { // Only process one file at a time. // If you upload 50 files, the controller's "Upload" method is called a total of 50 times. var element = file.Element; if (!element.IsEmpty) { // Saves the uploaded file. element.Save(); ... // Records the response data so that DEXTUploadX5 can receive it. return Content("response data", "text/plain", System.Text.Encoding.UTF8); } else { ... } }
The DEXTUploadX5 is not forwarding an empty file.
Therefore, "IsEmpty" property must always be "false". Otherwise, it should be noted that current request is not sent by the DEXTUploadX5.