Explanation
The large file upload is a feature that allows individual files to be transferred even if they exceed 2 GB. On the other hand, if the total size of the files to be uploaded (including other data) is less than 2GB, you do not need to use the large file upload.
When there are 10 files in the case of normal upload, ORAF transfers all 10 files in one transmission. When uploading in OROF mode, 10 times is transmitted because it is an individual transmission. In contrast, the large file upload requires at least 20 transfers to be performed, as well as individual file transfers, such as OROF, as individual files are sent to the server in chunks (blocks) divided by a predetermined size.
// Set the path to process the file upload.
dx.setUploadURL("http://../service/extension-upload.do");
// Set to "EXTS" to use the large file upload.
dx.setUploadMode("EXTS");
// Set the block size in bytes to split the file.
dx.setUploadBlockSize(10 * 1024 * 1024);
DEXTUploadX5 acts as a sender to send files. DEXTUploadNJ, on the other hand, acts as a receiver to receive files on the server side.
This sample is handled by the servlet (ExtensionUpload class) and is mapped to extension-upload.do in web.xml.
ExtensionFileUploadFilter class preprocesses to create a temporary file on the server by splitting the split files together. Once the temporary file has been created, pass the uploaded result to the ExtensionUpload servlet. So in the servlet(ExtensionUpload) code, you can treat it as if a complete file were delivered, like OROF.
Set the ExtensionFileUploadFilter filter in web.xml as follows.
<!-- web.xml --> <filter> <filter-name>extensionUploadFilter</filter-name> <filter-class>devpia.dextuploadnj.support.common.ExtensionFileUploadFilter</filter-class> <init-param> <param-name>tempRepository</param-name> <param-value>files/temp</param-value> </init-param> <init-param> <param-name>defaultRepository</param-name> <param-value>files/store</param-value> </init-param> <init-param> <param-name>autoMakingDirectory</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>enableCleaner</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>timeAgo</param-name> <param-value>24</param-value> </init-param> <init-param> <param-name>licenseFilePath</param-name> <param-value>WEB-INF/dextuploadnj.config</param-value> </init-param> </filter> <filter-mapping> <filter-name>extensionUploadFilter</filter-name> <servlet-name>ExtensionUpload</servlet-name> </filter-mapping>
In the ExtensionUpload servlet, you can use the FileUpload object to receive the file information.
FileUpload dextnj = null;
try {
dextnj = new FileUpload(request);
dextnj.prepare();
// Lareg file upload processes only one file like OROF upload method.
FileItem item = dextnj.getFileItem();
if (item.isEmpty() == false) {
// If there is no directory path given as an argument, the path set by defaultRepository parameter value of extensionUploadFilter filter is targeted.
item.save();
...
}
...
} finally {
// Remove the resource.
if (dextnj != null) dextnj.close();
}
Saving to a desired location using the FileItem#save method can be very slow, as opposed to creating a large temporary file on the server via the ExtensionFileUploadFilter filter. This is because the process of storing large files in the target location on the server is done through the 'copy' operation. If the temporary file is created and the final location is the same partition, it will be 'moved' instead of 'copying', so it can be processed very quickly.