Last updated: Oct 20 2016

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 2GB. 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

episerverapi/commerce/import/upload/chunk/{uploadId:guid=00000000-0000-0000-0000-000000000000}/{offset:int=0}
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, it creates a new upload identifier. If offset is not passed in, it uses offset of 0.

Typical uses

  • Send a PUT request to episerverapi/commerce/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

episerverapi/commerce/import/upload/commit/{uploadId:guid}/{overwrite:bool=true}
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.

Comments