Skip to content

Example 14

Steffen Habermehl edited this page Mar 23, 2017 · 7 revisions

Large files: How to use file chunking

Backload. has built in support for chunked file uploads since release 1.9.3.6. This optimizes memory usage significantly and improves large file scenarios. Additionally, large chunked files are not fully loaded into memory when they are finally merged. You do not have to configure Backload for file chunking support, because the component recognizes it automatically. You only need to configure your client side JavaScript plugin to split large files into chunks. The component stores the file chunks in the upload folder and merges them when the last chunk is uploaded.

How to add chunked file upload

You only need to setup your client side plugin (JQuery File Upload Plugin in this example):

// Initialize the jQuery File Upload widget: 
$('#fileupload').fileupload({
   url: fileUploadUrl,                           // URL to the Backload handler
   maxChunkSize: 10000000,                       // Max. chunk size 10MB
   acceptFileTypes: /(jpg)|(jpeg)|(png)|(zip)$/i // Allowed file types
});

Note

Each file chunk produces a new request. If your file chunks have a size of 10MB and you want to upload a 1GB file, around 100 requests will be sent to the server. If you want an optimized behaviour, you can dynamically intercept your client side plugin to produce chunk sizes based on the file size (e.g. 50MB chunks for a 1GB file, 10MB chunks for a 100MB file). Files will be chunked only if the file size is larger than the defined chunk size.

Conclusion

This example showed you how to setup chunked file support with the Backload. component. You only need tell the client side component to send chunked files. If your application must handle very large files, do not set the chunk size to very small values. Alternatively intercept the request before it is sent to the server and set the chunk size dynamically based on the current file size.

 

You can’t perform that action at this time.