Step 3: Chunk assets

Split assets into chunks that will be uploaded into Orange Logic simultaneously

Next, you’ll split your assets into small, binary chunks. We recommend using chunks of 1 to 128 MB. Smaller chunks allow Orange Logic to increase parallelization and decrease transfer speed, which allows your assets to be uploaded most efficiently. Additionally, if an error occurs and you need to re-upload a chunk, you’ll use fewer resources re-uploading a small chunk than you would a big chunk.

In the next step, you’ll use one API call per chunk, and you’ll need each chunk’s starting and ending positions. Additionally, you’ll need the total size of the full asset in bytes.

Split your asset into file chunks

File chunks must be equivalent sizes that are multiples of 131072 binary bytes (128 KB), except for the last chunk, which is the remainder of the file. The API call takes the starting and ending byte position of each chunk, starting at position 0.

For example, let’s say you want to upload an MP4 file with a total size of 85997454 bytes. You use 26214400 B (a multiple of 131072 B) as your file chunk size. You divide the total file size by your file chunk size to determine the number of chunks to create. This results in a value of approximately 3.28, so you will split your file into four chunks:

  • Three 26214400 B chunks.
  • One chunk that includes the remaining 7354253 B of the file.

These four chunks have the following starting and ending positions:

File ChunkStarting position (B)Ending position (B)
1026214399
22621440052428799
35242880078643199
47864320085997453

How to chunk files

The way you split assets into file chunks depends on your operating system. Use the following resources to help you split files correctly: