Loading...

Upload a File to an ObjectStore (REST API: POST)

This operation uploads a single file to the ObjectStore. The API is used for uploading files that are relatively small in size. You can also verify the file integrity using Secure Hash Algorithm (SHA) - 256 cryptographic hash function. For more information, see File Integrity Check.

For larger files (greater than 4 MB), upload the files in multiple data chunks. For more information, see Upload a File in Chunks.

Request

Syntax

POST <webservice>/contentstore/file/action/upload?uploadType=fullFile HTTP/1.1
Host: <host name>
Accept: application/xml
Authtoken: <authentication token>
ExternalFileGUID: <GUID from an external source>
FileName: <file name in base64 format>
FileSize: <file size in bytes>
FileModifiedtime: <modified time in UNIX timestamp>
ParentFolderPath: <file path in base64 format>
FullFileHash: <SHA hash of the file>
<file contents>

where <webservice> is the root path used to route the API requests to the Web Server.

For more information, see Available Web Services for REST API.

Request Headers

Name

Description

Host

The host name of the Web Server or Web Console used in the API request.

Accept

The format of the response. Valid values are: application/xml or application/json.

Authtoken

The authentication token received after successfully logging on. For details on receiving an authentication token, see Authentication.

ExternalFileGUID

(optional) If you have a 128-bit globally unique identifier (GUID) outside of the Commvault software, you can add it as a header so that it is assigned as the fileGUID for the file you are uploading.

If you send a GUID that includes hyphens, the hyphens are removed. Any request or search that uses your GUID must not include the hyphens.

FileName

Name of the file to be uploaded. The name must be base64 encoded.

FileSize

Size (in bytes) of the file to be uploaded.

FileModifiedtime

The last modified time of the file to be uploaded. Provide the value in UNIX timestamp format (in seconds). For example, 1424813723.

ParentFolderPath

The path to the destination folder where the file will be uploaded. The path must be relative from the root path and base64 encoded.

FullFileHash

(optional) The SHA hash of the complete file. Use SHA 256 to compute the hash value.

SkipPreview

Specifies whether to display a preview of the file after the upload. Valid values are 0 and 1.

To skip the file preview, enter the value 1.

If you want to display the file preview, you can skip this header or enter the value 0.

Request Body

Include the entire file contents. Do not include the content-type header.

Response

Response Parameters

Parameter

Description

Element

chunkOffset

The number of bytes received by the Web Server for the uploaded file.

DM2ContentIndexing_UploadFileResp

fileGUID

The GUID of the uploaded file.

DM2ContentIndexing_UploadFileResp

fileIntegrityVerified (optional)

Value 1 indicates that the hash value is identical and the file integrity check is verified.

DM2ContentIndexing_UploadFileResp

errorCode

The possible error codes.

Valid values are:

  • 200, successful completion.
  • a specific error code.

response

Examples

Sample Request

This sample request uploads a file and displays a preview of the file after the upload.

POST <webservice>/contentstore/file/action/upload?uploadType=fullFile HTTP/1.1
Host: client.mydomain.com
Accept: application/xml
Authtoken: QSDK 38568012f4d1e8ee1841d283a47aa3ba78e124ea58354b5fc6
0f4dab8a63347d05cf5552484dafda3bfa4c5db84e580b1cb37bcf8e65b39f7f
8549a443e6f78a2c7be3f31b3d845e24776c835e498e8e883bb40c46bd15af4f
40ca94e823acedcdd4e9659e74b34a07a85c4586cd2ed914b6dce015874783ef7
68fda78183a4208930954a377f66eb56c8b92cexampl4s437a19317ca6ce7f323
3d5a01aca35dbad93468b833f2cf71010809006a937670adce711ca8be46638e8
FileName: Zmxvd2Vycy50eHQ=
FileSize: 845941
FileModifiedtime: 1424813723
FullFileHash: f666c37a95e2f0ce1a9318130a16f3709879832136310b6a7ca07b75ae594e3c
ParentFolderPath: XHBsYW50cw0K
SkipPreview: 1
<file contents>

Supported Error Codes

Code

Status

Description

400

Bad Request

The request is missing required headers or file content in the request body.

Make sure the parameter values and format in the header request are correct. For example, the header request for file modified time must be specified in UNIX timestamp format (in seconds). Specifying a millisecond value will return an error. Also, the name must be base64 encoded.

403

Forbidden

Error due to one of the following reasons:

  • The user does not have rights to upload the file.
  • The upload operation is disabled by the administrator by disabling backup activity from the CommCell Console.
  • File Integrity check failed. The hash value in the header did not match with the hash value of the uploaded file.

409

Conflict

An upload operation is already in progress for the same file. The response body will have the existing requestId and the number of bytes that the web server has already received for the file. Example:

<DM2ContentIndexing_UploadFileResp requestId="13213022088234198160108125214183230586134182" chunkOffset="780830" errorCode="409" />

When a conflict occurs,

  • Use the same requestID to resume a chunk file upload from the byte offset sent from the server by sending data chunks.
  • Use the following URL parameter to force restart the upload of the file from the beginning. If this approach is used a new upload request session will be initiated and response will have the requestID.  Using the new requestID, the file data can be sent from beginning.

    /contentstore/file/action/upload?uploadType=fullFile&forceRestart=true

413

Request Entity Too Large

Upload attempted for a large file (greater than 4MB). For large files, upload the files in multiple data chunks. For more information, see Upload a File in Chunks.

Last modified: 12/18/2018 6:44:51 PM