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.
DEXTUploadNJSpringExtensionUploadFilter filter class preprocesses to create a temporary file on the server by merging the split files altogether. When a temporary file is created, it passes to the ExtensionFileServiceController.
Set the DEXTUploadNJSpringExtensionUploadFilter filter in web.xml as follows.
<!-- web.xml --> <filter> <filter-name>extensionUploadFilter</filter-name> <filter-class>devpia.dextuploadnj.support.spring.DEXTUploadNJSpringExtensionUploadFilter</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> <url-pattern>*.ext</url-pattern> </filter-mapping>
You can receive upload information from the mapped method of ExtensionFileServiceController.
/**
* If you send a total of 10 files, the mapping method will be called 10 times in total.
*/
@RequestMapping(value = "/service/extension-upload.ext", method = RequestMethod.POST)
public void extensionupload(DEXTUploadX5Request x5, HttpServletResponse response) throws IOException {
FileItem item = (FileItem)x5.getDEXTUploadX5_FileData().get(0);
if (item.isEmpty() == false) {
item.save();
...
}
...
}
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 DEXTUploadNJSpringExtensionUploadFilter 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.