Chunk up a large file then upload to Anaplan

For large files, split the file into chunks and upload each chunk separately. The first chunk might represent the entire file, or the file might consist of multiple chunks. If the file is larger than 1 MB, PUT each chunk to the server by streaming the chunk as an octet stream.

Use the Content-Type: application/octet-stream header.

PUT /workspaces/{workspaceId}/models/{modelId}/files/{fileId}/chunks/{chunkId}

ParameterDescription
workspaceIdThe workspace ID.
modelIdThe model ID.
fileIdThe file ID.
chunkIdThe chunk ID of the file. For example, the first chunk can use 0.

A successful chunk upload returns:

204 No Content

You can split a file into chunks before upload by using a shell command such as split.

Syntax: split -b [number of bytes] [path and filename] [prefix for output files]

Example: split -b 15360 ArchivedOpportunities.csv chunk-

This command splits ArchivedOpportunities.csv into chunk files that use chunk- as the output file prefix.

Specify a chunk size no larger than 50 MB of uncompressed data.

Use no more than 1,000 chunks per file.

For larger chunks, compressing the chunks can reduce upload time.

You can compress chunk files before upload.

For example, this shell command compresses all files in the current folder and folders below it if the files do not already have the .gz extension: find . -type f ! -name '*.gz' -exec gzip "{}" \;

If you upload compressed chunks, use this header instead of Content-Type: application/octet-stream:

Content-Type: application/x-gzip

The chunks must be compressed with the gzip format.

After uploading chunks with chunkCount set to -1, mark the upload as complete.

POST /workspaces/{workspaceId}/models/{modelId}/files/{fileId}/complete

ParameterDescription
workspaceIdThe workspace ID.
modelIdThe model ID.
fileIdThe file ID.

Use Content-Type: application/json.

The request body includes file metadata such as:

{
 "id": "113000000008",
 "name": "Tests.txt",
 "chunkCount": 1,
 "firstDataRow": 2,
 "headerRow": 1
}

A successful completion request returns a JSON response with the file metadata.

You can download files that were uploaded, or download files after carrying out an export.

To download a file in chunks:

  1. Get the list of files for the model.
  2. Identify the file you want to download.
  3. Get the chunks in the file.
  4. Download the data in each chunk.

Use the file list endpoint to get import and export files for a model.

GET /workspaces/{workspaceId}/models/{modelId}/files

ParameterDescription
workspaceIdThe workspace ID.
modelIdThe model ID.

A successful response returns JSON with a files array.

Each file object can include values such as id, name, chunkCount, encoding, firstDataRow, format, headerRow, and separator.

To download a file in chunks, first get the ID of each chunk.

GET /workspaces/{workspaceId}/models/{modelId}/files/{fileId}/chunks

ParameterDescription
workspaceIdThe workspace ID.
modelIdThe model ID.
fileIdThe file ID.

A successful response returns JSON with a chunks array.

Example chunk objects:

{
 "id": "0",
 "name": "Chunk 0"
}

After you know the chunk ID, download the data for that chunk.

GET /workspaces/{workspaceId}/models/{modelId}/files/{fileId}/chunks/{chunkId}

ParameterDescription
workspaceIdThe workspace ID.
modelIdThe model ID.
fileIdThe file ID.
chunkIdThe chunk ID of the file.

You can delete files that you uploaded through the API.

Deleting a file removes only private content. Default content and the import data source model object remain.

DELETE /workspaces/{workspaceId}/models/{modelId}/files/{fileId}

ParameterDescription
workspaceIdThe workspace ID.
modelIdThe model ID.
fileIdThe file ID.