Upload a File to Edge Drive Share (REST API: POST)

Updated

This operation uploads a single file to a shared folder in Edge Drive. 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 Initiate an Upload Session.

Request

Syntax

POST <webservice>/drive/share/{shareId}/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 Parameters

Name

Description

Required

shareId

The unique identifier (syncWebFolderId response) returned when you share a file or folder or view the shared files and folders in Edge Drive. For details on retrieving the syncWebFolderId response, see Sharing a File or Folder or Viewing Shared Files and Folders.

Yes

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

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

FileSize

The size (in bytes) of the file to 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.

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

POST <webservice>/drive/share/37/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

ParentFolderPath: XHBsYW50cw0K

FullFileHash: f666c37a95e2f0ce1a9318130a16f3709879832136310b6a7ca07b75ae594e3c

<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 Initiate an Upload Session.