Area: Episerver Service API
Applies to versions: 1 and higher

Chunk upload of large files

EPiServer.ServiceApi allows for bulk operations, which upload files to be imported. ASP.NET has a maximum limit of 2 GB. Because allowing such large requests can be a security risk to your site, the service API lets you upload files in chunks to be used later for import.

Example model

Upload chunk

This method uploads large files to the service API in multiple chunks. It also can resume if the upload is interrupted. If an uploadId is not passed in, this method creates a new upload identifier. If an offset is not passed in, it uses offset of 0.

Typical uses

  • Send a PUT request to episerverapi/commerce/import/upload/chunk with the first chunk of the file without setting uploadId, and receive an uploadId in return.
  • Repeatedly PUT subsequent chunks using the upload_id to identify the upload in progress and an offset representing the number of bytes transferred so far.
  • After the last chunk, POST to episerverapi/commerce/import/upload/commit to complete the upload.

Commit chunked upload

This method commits the chunked uploads associated with the upload identifier, and creates a whole file to be used in a separate import call. The default value overwrites the file if the completed file already exists on the server for this upload identifier. The method returns the upload identifier if the upload was successfully committed.

Delete chunk uploaded


This method recursively deletes chunked uploads associated with the upload identifier.

If the deletion is successful, the method returns a "no content" status code. If the upload identifier does not exist, the method returns a "not found" status. Otherwise, it returns an internal server error with an exception message.

Note: You can also delete old uploaded files and directories using the Commerce scheduled job "Remove old Service API uploaded files and directories." You might use the scheduled job in situations where you upload chunked files but forget to call the Commit API. The scheduled job ensures that the files will eventually be removed.

Last updated: Oct 20, 2016