Chunk Upload
You can use the Upload to split files into chunks and send them asynchronously through multiple requests to the server.
Setup
To enable file chunking, configure the chunkable option. It accepts both boolean
and ChunkSettings parameters.
If you use a ChunkSettings parameter, the Upload enables you to specify the following options:
size
—Determines the size of each chunk in bytes. The default value is1048576
i.e. 1MB.autoRetryAfter
—Will attempt a failed chunk upload after the specified number of milliseconds. The default value is100
.maxAutoRetries
—Determines the number of attempts to retry uploading a failed chunk. The default value is1
.resumable
—Determines if the file upload process could be paused and later resumed. The default value istrue
.
If you use a boolean
parameter and set the value to true
, the component will apply the default ChunkSettings values.
Along with the uploaded file chunk, the FormData
contains a JSON stringified ChunkMetadata object with the following information:
contentType
—The MIME type of the file.fileName
—The name of the file.fileSize
—The size of the file.fileUid
—The unique identifier of the file.chunkIndex
—The index of the currently uploaded chunk.totalChunks
—The total number of chunks that the file is split in.
You can use this information to reconstruct the original file on the backend.
Sequential Chunk Upload
By default all files are uploaded concurrently. In order to upload the files one by one, set the concurrent option to false
.
Disable Pause
In order to upload the files without allowing the user to pause the upload process, set the resumable
option of the ChunkSettings parameter to false
.