目录

This section describes the procedures for integrating HUAWEI Drive Kit into your app and provides relevant guidance to help you quickly learn the server APIs provided by HUAWEI Drive Kit and the methods of calling these APIs. You may choose to read any applicable subsections below based on your specific use cases. For details about the use cases, please refer to section Use Cases under Service Introduction.

1 Functions

Major capabilities provided by the Drive RESTful APIs and the corresponding call methods include:

1.Obtaining user information and the authorization page through the About.get() API

2.Implementing file management and search functions through the Files APIs

3.Subscribing to the channels for tracking file changes and enabling the file change notification function through the Changes APIs.

4.Commenting on files using the Comments API.

5.Replying to comments using the Replies API.

2 Obtaining Authentication Information

2.1 Use Case

HUAWEI ID is the account that a user uses to access and manage their files in Drive. Before initializing Drive, your app will need to prompt the user to sign in with their HUAWEI ID. After the user signs in, the app can call Drive RESTful APIs to implement Drive functions based on the user's HUAWEI ID information.

2.2 Service Process2.2 Service Process

                                              

Process Description

1. The user signs in to the app by using a HUAWEI ID.

2. The app sends a sign-in request to the HMS SDK.

3. The HUAWEI Account server displays the user sign-in and authorization page, explicitly notifying the user of the content to be authorized based on the scope carried in the sign-in request.

4. After the user manually authorizes the app to access the content in question,the HUAWEI Account server returns an authorization code to the app.

5. The app sends the API call request that carries the authorization code and other necessary parameters to the HUAWEI Drive server.

6. The HUAWEI Drive server performs relevant processing and returns the processing result.

2.3 Development Procedure

1. Integrate the HMS SDK.

To use Drive RESTful APIs, your app will need to obtain user information through the HMS SDK first. For details, please refer to Integrating the HMS SDK.

2. Set the HMS scope.

Set the Drive scope through the HuaweiIdAuthParamsHelper.setScopeList API provided by the HMS SDK, for obtaining the permission to access Drive APIs.

  1. List<Scope> scopeList = new LinkedList<>();
  2. scopeList.add(HuaweiIdAuthAPIManager.HUAWEIID_BASE_SCOPE);// Basic account permissions
  3. scopeList.add(new Scope(DRIVE));// All permissions, except permissions for the app folder.
  4. scopeList.add(new Scope(DRIVE_FILE));// Permissions to view and manage files.
  5. scopeList.add(new Scope(DRIVE_METADATA));// Permissions to view and manage file metadata, excluding file content.
  6. scopeList.add(new Scope(DRIVE_METADATA_READONLY));// Permissions only for viewing file metadata, excluding file content.
  7. scopeList.add(new Scope(DRIVE_READONLY));// Permissions to view file metadata and content.
  8. scopeList.add(new Scope(DRIVE_APPDATA));// Permissions to view and manage app files.
  9. HuaweiIdAuthParams params = new HuaweiIdAuthParamsHelper(HuaweiIdAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
  10.         .setAccessToken()
  11.         .setIdToken()
  12.         .setScopeList(scopeList)
  13.         .createParams();

Each Drive scope corresponds to a certain type of permissions. You may apply for the permissions as needed. For details about the sign-in process, please refer to Signing In with HUAWEI ID.

Scopes

Constant

Value and Description

DRIVE

https://www.huawei.com/auth/drive

All permissions, except those for the app folder.

DRIVE_FILE

https://www.huawei.com/auth/drive.file

Permissions to view and manage files.

DRIVE_METADATA_READONLY

https://www.huawei.com/auth/drive.readonly

Permissions to view file content and metadata.

DRIVE_READONLY

https://www.huawei.com/auth/drive.metadata

Permissions to view and manage file metadata, excluding file content.

DRIVE_METADATA

https://www.huawei.com/auth/drive.metadata.readonly

Permissions to view file metadata, excluding file content.

DRIVE_APPDATA

https://www.huawei.com/auth/drive.appdata

Permissions to upload and store app data.

3. Store authentication information.

After obtaining the user information, save the AccessToken of the user for calling the Drive RESTful APIs whenever needed.

Notice:
After obtaining the authentication information, your app must check whether the user's security policy needs to be updated. For details, please refer to Obtaining User Information.

3 Obtaining User Information

3.1 Use Case

By calling the About.get API, your app can obtain a user's Drive information, such as its storage quota limit and maximum size of a file that can be uploaded by the user.

3.2 Obtaining User Information

Introduction

Obtains user information using the About.get API.

Restrictions

1. Mandatory parameter: fields

2. Currently, the form parameter has a fixed value of json. If the parameter is left empty, json is used by default.

3. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.readonly

    https://www.huawei.com/auth/drive.metadata

    https://www.huawei.com/auth/drive.metadata.readonly

Sending a Request to Obtain User Information

Step 1 Create a GET request to the About API.

Step 2 Set the query parameter fields=*.

Example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/about?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. GET https:// drive.cloud.hicloud.com/drive/v1/about?fields=* HTTP/1.1
  2. Accept: application/json
  3. Cache-Control: no-cache
  4. Authorization: Bearer CF3NTYZSs7MRmxWyj8ssonQQxDgSPAjnDvrf+91NrpN22LdUrMA30A5Kzz0mf55sWao7e7VeLrmjQ0z2OmwPWlt3S00/L1BJppbTFhIgWb74ZBK8CFImUA==

Response example:

If successful, the server returns the HTTP 200 OK status code.

  1. {
  2.    "storageQuota": {
  3.        "usedSpace": "11244",
  4.        "userCapacity": "5368709120"
  5.    },
  6.    "maxThumbnailSize": 819200,
  7.    "needUpdate": false, //If the value is true, the user needs to update the security policy.
  8.    "domain": "drive.cloud.hicloud.com",
  9.    "maxFileUploadSize": "5368709120",
  10.    "category": "drive#about",
  11.    "user": {
  12.        "permissionId": "239046878371512704",
  13.        "displayName": "*******3121@**3.com",
  14.        "me": true,
  15.        "category": "drive#user"
  16.    }
  17. }

4 Managing and Searching for Files

4.1 Use Case

File management is a core capability of HUAWEI Drive Kit. It enables users to conveniently manage and edit files in Drive, including creating, listing, copying, modifying, deleting, trashing, and searching for files.


Introduction

Lists folders or files based on a set of conditions using the Files.list API.

Restrictions

1. The fields parameter is optional. Its value must meet the format requirements of a partial response.

2. The queryParam parameter is used to filter files by property. Its options are parentFolder and fileName.

3. The orderBy parameter is a list of sort keys separated by commas. Its options are createdTime, folder, editedTime, fileName, sharedWithMeTime, favorite, and size. Each key sorts in ascending order by default, but can be reversed with the desc modifier. Example: orderBy=folder,editedTimedesc,fileName. If the number of files exceeds 100,000, orderBy is ignored.

4. The pageSize parameter has a default value of 100. Its value ranges from 1 to 100. If it is left empty or set to a negative number, the default value 100 will be used instead.

5. The containers parameter indicates the query scope. Its value can be drive, applicationData, or a combination of the two (separated by a comma). The default value is drive.

6. The file name does not support emoji and invalid characters such as angle brackets (<>), vertical lines (|), colons (:), quotation marks ("), asterisks (*), question marks (?), forward slashes (/), and back slashes (\).

7. Currently, the form parameter has a fixed value of json. If the parameter is left empty, json is used by default.

8. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.readonly

    https://www.huawei.com/auth/drive.metadata

    https://www.huawei.com/auth/drive.metadata.readonly

Sending a Request to List Files

Step 1 Create a GET request to the Files.list API.

Step 2 Set HTTP header fields.

Accept: media type that is acceptable for the response

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 3 Send the request.

Request example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files HTTP/1.1
  2. Content-Type: application/json
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  4. Cache-Control: no-cache
  5. Accept: application/json

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "files": [
  4.        {
  5.            "fileName": "noname1583417266285",
  6.            "sha256": "86041fa5f0e85ac7681191eda329527af803fa8f3b512896746e60436c496698",
  7.            "owners": [
  8.                {
  9.                    "permissionId": "239046878371512704",
  10.                    "displayName": "*******3121@**3.com",
  11.                    "me": true,
  12.                    "category": "drive#user"
  13.                }
  14.            ],
  15.            "hasShared": false,
  16.            "mimeType": "image/jpeg",
  17.            "permissionIds": [
  18.                "239046878371512704"
  19.            ],
  20.            "lastHistoryVersionId": "ABwJAOm8CuoCKUwJk4lP43gRTA-ThArsA",
  21.            "parentFolder": [
  22.                "AgFovWXIAIYANC20H_1Fj3oMLbIf8ACAA"
  23.            ],
  24.            "recycled": false,
  25.            "directlyRecycled": false,
  26.            "permissions": [
  27.                {
  28.                    "canDiscoverFile": true,
  29.                    "role": "owner",
  30.                    "displayName": "*******3121@**3.com",
  31.                    "id": "239046878371512704",
  32.                    "category": "drive#permission",
  33.                    "type": "user"
  34.                }
  35.            ],
  36.            "occupiedSpace": 3748,
  37.            "createdTime": "2020-03-05T14:07:47.000Z",
  38.            "id": "ABwJAOm8CuoCKUwJk4lP43gRTA-ThArsA",
  39.            "contentDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/files/ABwJAOm8CuoCKUwJk4lP43gRTA-ThArsA?form=content",
  40.            "smallThumbnailDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/smallThumbnails/ABwJAOm8CuoCKUwJk4lP43gRTA-ThArsA?form=content",
  41.            "capabilities": {
  42.                "renameFilePermission": true,
  43.                "downloadPermission": true,
  44.                "commentPermission": true,
  45.                "deletePermission": true,
  46.                "readHistoryVersionPermission": true,
  47.                "recyclePermission": true,
  48.                "addChildNodePermission": false,
  49.                "unrecyclePermission": true,
  50.                "writerHasChangeCopyPermission": false,
  51.                "editContentPermission": true,
  52.                "copyPermission": true,
  53.                "removeChildNodePermission": false,
  54.                "editPermission": true,
  55.                "shareFilePermission": true,
  56.                "listChildNodePermission": false
  57.            },
  58.            "ownedByMe": true,
  59.            "thumbnailDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/thumbnails/ABwJAOm8CuoCKUwJk4lP43gRTA-ThArsA?form=content",
  60.            "pictureMetadata": {
  61.                "width": 306,
  62.                "height": 165
  63.            },
  64.            "editedTime": "2020-03-05T14:07:47.000Z",
  65.            "iconDownloadLink": "https://event-dre.dbankcdn.com/filemanagerpic/201911140913476Sc7.png",
  66.            "size": 3748,
  67.            "thumbnailVersion": 0,
  68.            "writerHasCopyPermission": false,
  69.            "lastEditor": {
  70.                "permissionId": "239046878371512704",
  71.                "displayName": "*******3121@**3.com",
  72.                "me": true,
  73.                "category": "drive#user"
  74.            },
  75.            "existThumbnail": true,
  76.            "containers": [
  77.                "drive"
  78.            ],
  79.            "category": "drive#file",
  80.            "favorite": false,
  81.            "contentVersion": "916481f1-8d1c-3cf3-9975-316c6f0c8423"
  82.        },
  83.        {
  84.            "fileName": "noname1583319432882",
  85.            "sha256": "86041fa5f0e85ac7681191eda329527af803fa8f3b512896746e60436c496698",
  86.            "owners": [
  87.                {
  88.                    "permissionId": "239046878371512704",
  89.                    "displayName": "*******3121@**3.com",
  90.                    "me": true,
  91.                    "category": "drive#user"
  92.                }
  93.            ],
  94.            "hasShared": false,
  95.            "mimeType": "image/jpeg",
  96.            "permissionIds": [
  97.                "239046878371512704"
  98.            ],
  99.            "lastHistoryVersionId": "ABwFaogkCuoCKUBj8hFP43gRQGXyHArsA",
  100.            "parentFolder": [
  101.                "AgFovWXIAIYANC20H_1Fj3oMLbIf8ACAA"
  102.            ],
  103.            "recycled": false,
  104.            "directlyRecycled": false,
  105.            "permissions": [
  106.                {
  107.                    "canDiscoverFile": true,
  108.                    "role": "owner",
  109.                    "displayName": "*******3121@**3.com",
  110.                    "id": "239046878371512704",
  111.                    "category": "drive#permission",
  112.                    "type": "user"
  113.                }
  114.            ],
  115.            "occupiedSpace": 3748,
  116.            "createdTime": "2020-03-04T10:57:13.000Z",
  117.            "id": "ABwFaogkCuoCKUBj8hFP43gRQGXyHArsA",
  118.            "contentDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/files/ABwFaogkCuoCKUBj8hFP43gRQGXyHArsA?form=content",
  119.            "smallThumbnailDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/smallThumbnails/ABwFaogkCuoCKUBj8hFP43gRQGXyHArsA?form=content",
  120.            "capabilities": {
  121.                "renameFilePermission": true,
  122.                "downloadPermission": true,
  123.                "commentPermission": true,
  124.                "deletePermission": true,
  125.                "readHistoryVersionPermission": true,
  126.                "recyclePermission": true,
  127.                "addChildNodePermission": false,
  128.                "unrecyclePermission": true,
  129.                "writerHasChangeCopyPermission": false,
  130.                "editContentPermission": true,
  131.                "copyPermission": true,
  132.                "removeChildNodePermission": false,
  133.                "editPermission": true,
  134.                "shareFilePermission": true,
  135.                "listChildNodePermission": false
  136.            },
  137.            "ownedByMe": true,
  138.            "thumbnailDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/thumbnails/ABwFaogkCuoCKUBj8hFP43gRQGXyHArsA?form=content",
  139.            "pictureMetadata": {
  140.                "width": 306,
  141.                "height": 165
  142.            },
  143.            "writersHasSharePermission": true,
  144.            "editedTime": "2020-03-04T10:57:13.000Z",
  145.            "iconDownloadLink": "https://event-dre.dbankcdn.com/filemanagerpic/201911140913476Sc7.png",
  146.            "size": 3748,
  147.            "thumbnailVersion": 0,
  148.            "writerHasCopyPermission": false,
  149.            "lastEditor": {
  150.                "permissionId": "239046878371512704",
  151.                "displayName": "*******3121@**3.com",
  152.                "me": true,
  153.                "category": "drive#user"
  154.            },
  155.            "existThumbnail": true,
  156.            "containers": [
  157.                "drive"
  158.            ],
  159.            "category": "drive#file",
  160.            "favorite": false,
  161.            "contentVersion": "916481f1-8d1c-3cf3-9975-316c6f0c8423"
  162.        }
  163.    ],
  164.    "category": "drive#fileList"
  165. }

4.3 Emptying the Recycle Bin

Introduction

Empties the recycle bin of a user's Drive or that of your app using the Files.emptyRecycle API.

Restrictions

1. The containers parameter is optional. Its value can be drive, applicationData, or a combination of the two (separated by a comma). If containers is not set, the default value drive is used.

2. If containers is set to drive and scope is set to https://www.huawei.com/auth/drive, the recycle bin of the user's Drive will be emptied using the API.

3. If containers is set to applicationData and scope is set to https://www.huawei.com/auth/drive.appdata, the recycle bin of your app will be emptied using the API.

4. If containers is set to drive,applicationData and scope is set to https://www.huawei.com/auth/drive and https://www.huawei.com/auth/drive.appdata, both the recycle bins of the user's Drive and your app will be emptied using the API.

Sending a Request to Empty Recycle Bin

Step 1 Create a DELETE request to the Files.emptyRecycle API.

Step 2 Set HTTP header fields.

Authorization: authorization code obtained from the HUAWEI Account server

Step 3 Send the request.

Request example:

  1. DELETE https://drive.cloud.hicloud.com/drive/v1/files/recycle HTTP/1.1
  2. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk

Response example:

  1. HTTP/1.1 204 OK

4.4 Tracking File Changes

Introduction

Tracks changes made to a file or folder shared to multiple users using the Files.subscribe API.

Restrictions

1. Mandatory parameters: fileId, cursor, id, type, and url

2. URL parameters are controlled by a whitelist, namely, only URLs in the whitelist are allowed.

3. type: Currently, its value is web_hook.

4. expirationTime: Its value is expressed as a Unix timestamp.

5. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.readonly

    https://www.huawei.com/auth/drive.metadata

    https://www.huawei.com/auth/drive.metadata.readonly

Sending a Request to Track File Changes

Step 1 Create a POST request to the Files.subscribe API.

Step 2 Set the query parameters {fileId} and fields=*.

Example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/subscribe?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/files/DSQpEkxcAAADKXEPJAYABgOUVrNwA8Cu/subscribe?fields=* HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  5. Cache-Control: no-cache
  6. {
  7.    "url": "https://www.huawei.com",
  8.    "expirationTime": "1583419819000",//Set this parameter to zero to one day from the current time, expressed as a Unix timestamp. If the parameter is left empty, one hour will be used by default.
  9.    "id": "101207111",
  10.    "type": "web_hook",
  11.    "userToken": "F0Ge0"
  12. }

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "userToken": "F0Ge0",
  4.    "resourceId": "MTIzOTA0Njg3ODM3MTUxMjcwNHxBQndKQU9tOEN1b0NLVXdKazRsUDQzZ1JUQS1UaEFyc0E",
  5.    "expirationTime": 1583419819000,
  6.    "id": "101207111",
  7.    "resourceUri": "https://drive.hicloud.com/drive/v1/files/ABwJAOm8CuoCKUwJk4lP43gRTA-ThArsA?form=json&fields={fields}",
  8.    "category": "api#channel",
  9.    "type": "web_hook",  
  10.    "url": "https://www.huawei.com"
  11. }

4.5 Deleting a File

Introduction

Permanently deletes a file using the Files.delete API.

Restrictions

1. Only a common folder can be deleted. The root folder cannot be deleted.

2. The scope value must be one of the following:

https://www.huawei.com/auth/drive.file

https://www.huawei.com/auth/drive

https://www.huawei.com/auth/drive.appdata

3. If the parent folder or subfolder of a file or folder of the current user contains a folder created by a different user with the owner permission, the file or folder of the current user cannot be deleted. To delete the file or folder of the current user, first delete the folder of another user.

Sending a Request to Delete a File

Step 1 Create a DELETE request to the Files.delete API.

Step 2 Set the path parameter {fileId}.

Example:

  1. DELETE https://drive.cloud.hicloud.com/drive/v1/files/{fileId}

Step 3 Set HTTP header fields.

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. DELETE https://drive.cloud.hicloud.com/drive/v1/files/DSQpEkxcAAADKXEPJAYABgOUVrNwA8CuHTTP/1.1
  2. Content-Type: application/json
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  4. Cache-Control: no-cache

Response example:

  1. HTTP/1.1 204 OK

4.6 Modifying and Uploading a File (Multipart Mode)

Introduction

Updates the metadata (in whole), thumbnail, and content of a file (identified by fileId) using the Files.update.multipart API.

Restrictions

1. Mandatory parameters: fileId, uploadType, request body, and Content-Type

2. The value of Content-Type must be multipart/related, the value of uploadType must be multipart, and the request body must meet the format requirements of the multipart method.

3. Time parameters editedTime and createdTime in the metadata must comply with the RFC3339 format requirements.

4. To update the file, include the file content in the request.

5. The values of fileId, fileName, and description must not contain emoji.

6. The file name in a folder must be unique.

7. The addParentFolder and removeParentFolder parameters are optional. However, they must be both set or left empty.

8. appSettings: The value can consist of up to 30 key-value pairs.

9. All time parameters must comply with the RFC 3339 format requirements.

10. description: The value can neither contain emoji nor exceed 512 bytes.

11. fileName and originalFilename: The value can consist of up to 80 bytes, without supporting emoji and special characters including, angle brackets (<>), vertical lines (|), colons (:), quotation marks ("), asterisks (*), question marks (?), forward slashes (/), and back slashes (\).

12. parentFolder: The value cannot contain two consecutive dots (..).

13. properties: The value can consist of up to 30 key-value pairs. In each key-value pair, both the key and value must not exceed 124 bytes.

14. sha256: The value must be a string of 64 bytes and comply with the SHA-256 algorithm format requirements.

15. contentExtras: This parameter can be left empty. If it is set, the thumbnail content must be encoded using Base64 and cannot exceed 2 MB.If it is set to an invalid value, it will be ignored. In this case, a default thumbnail will be generated based on the supported file type.

16. The scope value must be one of the following:

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive.appfile

17. mimeType: Its value comply with the general format requirements.

18.A zero-byte file cannot be uploaded.

Sending a Request to Modify and Upload a File

Step 1 Create a PUT or PATCH request to the Files.update.multipart API.

Step 2 Set the query parameters {fileId}, uploadType=multipart, and fields=*.

Example:

  1. PUT/PATCH https://drive.cloud.hicloud.com/upload/drive/v1/files/{fileId}?uploadType=multipart&fields=*

Step 3 Set HTTP header fields.

Content-Type: type of the file to be uploaded

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. PUT/PATCH https://drive.cloud.hicloud.com/upload/drive/v1/files/AB9FPewYCuoCKgA0li1P43gSADKWIArsA?uploadType=multipart&fields=* HTTP/1.1
  2. Content-Type: multipart/related;boundary=OP8XTaXZ0UZs-Sjlefcj2OWskqXWwVQO
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  4. Cache-Control: no-cache
  5. --OP8XTaXZ0UZs-Sjlefcj2OWskqXWwVQO
  6. Content-Type: application/json
  7. //Line break is required
  8. {
  9.    "fileName":"zztest0014",
  10.    "contentExtras": {
  11.        "thumbnail":{
  12.            "content":"dGVzdDAwMw==",
  13.            "mimeType":"image/jpeg"
  14.        }
  15.    },
  16.    "parentFolder":["applicationData"]
  17. }
  18. --OP8XTaXZ0UZs-Sjlefcj2OWskqXWwVQO
  19. Content-Type: application/octet-stream
  20. //Line break is required
  21. [imageData]
  22. --OP8XTaXZ0UZs-Sjlefcj2OWskqXWwVQO--

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "category": "drive#file",
  4.    "id": "AB9FPewYCuoCKgA0li1P43gSADKWIArsA",
  5.    "fileName": "zztest0014",
  6.    "mimeType": "application/octet-stream",
  7.    "favorite": false,
  8.    "recycled": false,
  9.    "directlyRecycled": false,
  10.    "parentFolder": [
  11.        "AgFovWXIAIYANC20H_1Fj3oMLbIf8ACAA"
  12.    ],
  13.    "containers": [
  14.        "MyDrive"
  15.    ],
  16.    "version": 1584928312000,
  17.    "contentDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/files/AB9FPewYCuoCKgA0li1P43gSADKWIArsA?form=content",
  18.    "iconDownloadLink": "https://event-dre.dbankcdn.com/filemanagerpic/201911140913476Sc7.png",
  19.    "existThumbnail": false,
  20.    "thumbnailVersion": 0,
  21.    "createdTime": "2020-03-23T01:52:43.000Z",
  22.    "editedTime": "2020-03-23T01:52:43.000Z",
  23.    "owners": [
  24.        {
  25.            "category": "drive#user",
  26.            "displayName": "*******3121@**3.com",
  27.            "me": true,
  28.            "permissionId": "239046878371512704"
  29.        }
  30.    ],
  31.    "lastEditor": {
  32.        "category": "drive#user",
  33.        "displayName": "*******3121@**3.com",
  34.        "me": true,
  35.        "permissionId": "239046878371512704"
  36.    },
  37.    "hasShared": false,
  38.    "ownedByMe": true,
  39.    "capabilities": {
  40.        "addChildNodePermission": false,
  41.        "writerHasChangeCopyPermission": false,
  42.        "commentPermission": true,
  43.        "copyPermission": true,
  44.        "deletePermission": true,
  45.        "downloadPermission": true,
  46.        "editPermission": true,
  47.        "listChildNodePermission": false,
  48.        "editContentPermission": true,
  49.        "readHistoryVersionPermission": true,
  50.        "removeChildNodePermission": false,
  51.        "renameFilePermission": true,
  52.        "shareFilePermission": true,
  53.        "recyclePermission": true,
  54.        "unrecyclePermission": true
  55.    },
  56.    "permissions": [
  57.        {
  58.            "category": "drive#permission",
  59.            "id": "239046878371512704",
  60.            "type": "user",
  61.            "role": "owner",
  62.            "displayName": "*******3121@**3.com",
  63.            "allowFileDiscovery": true,
  64.            "deleted": false
  65.        }
  66.    ],
  67.    "permissionIds": [
  68.        "239046878371512704"
  69.    ],
  70.    "size": 7960,
  71.    "occupiedSpace": 7960,
  72.    "sha256": "cb823658e6d43cac59621523e9c7ed6e9d1c37f1fb6877174cfbb50cd21308d0",
  73.    "contentVersion": "54d53a55-f67e-3f5c-9c08-043752835352"
  74. }

4.7 Modifying a File and Preparing for Resumable Upload

Introduction

Initializes the update task for resumable upload using the Files.update.resume API, including updating all existing file metadata, parsing the file metadata, and obtaining the uploadId for resumable upload.

Restrictions

1. Mandatory path parameters: fileId and uploadType=resume

2. Mandatory request parameter: X-Upload-Content-Length

3. addParentFolder and removeParentFolder must be both set or left empty.

4. The request body can only be a JSON string or left empty.

5. The values of addParentFolder and removeParentFolder cannot be a path to the recycle bin.

6. appSettings: The value can consist of up to 30 key-value pairs.

7. All time parameters must comply with the RFC 3339 format requirements.

8. description: The value can neither contain emoji nor exceed 512 bytes.

9. fileName and originalFilename: The value can consist of up to 80 bytes, without supporting emoji and special characters including, angle brackets (<>), vertical lines (|), colons (:), quotation marks ("), asterisks (*), question marks (?), forward slashes (/), and back slashes (\).

10. parentFolder: The value cannot contain two consecutive dots (..).

11. properties: The value can consist of up to 30 key-value pairs. In each key-value pair, both the key and value must not exceed 124 bytes.

12. sha256: The value must be a string of 64 bytes and comply with the SHA-256 algorithm format requirements.

13. contentExtras: This parameter can be left empty. If it is set, the thumbnail content must be encoded using Base64 and cannot exceed 2 MB.If it is set to an invalid value, it will be ignored. In this case, a default thumbnail will be generated based on the supported file type.

14. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive

15. mimeType: Its value comply with the general format requirements.

Sending a Request to Modify a File and Prepare for Resumable Upload

Step 1 Create a PUT or PATCH request to the Files.update.resume API.

Step 2 Set the query parameters {fileId}, uploadType=resume, and fields=*.

Example:

  1. PUT/PATCH https://drive.cloud.hicloud.com/upload/drive/v1/files/{fileId}?uploadType=resume&fields=*

Step 3 Set HTTP header fields.

X-Upload-Content-Type: type of the file to be uploaded

X-Upload-Content-Length: length of the file to be uploaded

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. PUT/PATCH https://drive.cloud.hicloud.com/upload/drive/v1/files/DSQpEkxcAAADKXEPJAYABgEZivNwAmCu?uploadType=resume&fields=* HTTP/1.1
  2. X-Upload-Content-Type: image/jpeg
  3. X-Upload-Content-Length: 200000
  4. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  5. Cache-Control: no-cache
  6. {
  7.    "appSettings":{
  8.        "test1":"value1"
  9.    },
  10.    "contentExtras":{
  11.        "thumbnail":{
  12.            "content":"***",
  13.            "mimeType":"image/jpeg",
  14.            "thumbnailPublic":false
  15.        }
  16.    },
  17.    "writerHasCopyPermission":false,
  18.    "createdTime":"2019-11-14T07:53:24.953Z",
  19.    "description":"test test test zb",
  20.    "mimeType":"image/jpeg",
  21.    "editedTime":"2019-11-14T07:53:24.953Z",
  22.    "fileName":"1234.JPG",
  23.    "originalFilename":"3123.JPG",
  24.    "parentFolder":[
  25.        "/opt/test"
  26.    ],
  27.    "properties":{
  28.        "test2":"value2"
  29.    },
  30.    "favorite":true,
  31.    "writersHasSharePermission":false
  32. }

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "sliceSize":4194304
  4. }
  5. Headers:Location:https://drive.cloud.hicloud.com/upload/drive/v1/fc7300dbe0280d39/files?fields=*&uploadType=resume&uploadId=324314495017204480
  6. Content-Type: application/json; charset=utf-8
  7. Content-Length: 21

4.8 Modifying and Uploading a File (Content Mode)

Introduction

Updates a file (identified by fileId) using the Files.update.content API.

Restrictions

1. Mandatory parameters: fileId and uploadType

2. The value of uploadType must be content.

3. To update the file, include the file content in the request.

4. The fields parameter is optional. Its value must comply with the format requirements of a partial response.

5. The file name in a folder must be unique.

6. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.appdata

7. A zero-byte file cannot be uploaded.

Note

1. Use the Files.update.resume API to upload a file larger than 20 MB.

Sending a Request to Modify and Upload a File

Step 1 Create a PUT or PATCH request to the Files.update.content API.

Step 2 Set the query parameters uploadType=content and fields=*.

Example:

  1. PUT/PATCH https://drive.cloud.hicloud.com/upload/drive/v1/files/{fileId}?uploadType=content&fields=*

Step 3 Set HTTP header fields.

Content-Type: type of the file to be uploaded

Content-Length: length of the file to be uploaded

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. PUT/PATCH https://drive.cloud.hicloud.com/upload/drive/v1/files/DSQpEkxcAAADKXEPJAYABgEZivNwAmCu?uploadType=content&fields=* HTTP/1.1
  2. Content-Type: image/jpeg
  3. Content-Length: 200000
  4. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  5. Cache-Control: no-cache    
  6. [imageData]

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "category": "drive#file",
  4.    "id": "AB9FfdS4CuoCKgB0ro1P43gSAHKugArsA",
  5.    "fileName": "noname1584930462469",
  6.    "mimeType": "image/jpeg",
  7.    "favorite": false,
  8.    "recycled": false,
  9.    "directlyRecycled": false,
  10.    "parentFolder": [
  11.        "AgFovWXIAIYANC20H_1Fj3oMLbIf8ACAA"
  12.    ],
  13.    "containers": [
  14.        "MyDrive"
  15.    ],
  16.    "version": 1584932131000,
  17.    "contentDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/files/AB9FfdS4CuoCKgB0ro1P43gSAHKugArsA?form=content",
  18.    "iconDownloadLink": "https://event-dre.dbankcdn.com/filemanagerpic/201911140913476Sc7.png",
  19.    "existThumbnail": true,
  20.    "thumbnailDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/thumbnails/AB9FfdS4CuoCKgB0ro1P43gSAHKugArsA?form=content",
  21.    "smallThumbnailDownloadLink": "https:// drive.cloud.hicloud.com/drive/v1/smallThumbnails/AB9FfdS4CuoCKgB0ro1P43gSAHKugArsA?form=content",
  22.    "thumbnailVersion": 0,
  23.    "createdTime": "2020-03-23T02:27:44.000Z",
  24.    "editedTime": "2020-03-23T02:56:22.000Z",
  25.    "owners": [
  26.        {
  27.            "category": "drive#user",
  28.            "displayName": "*******3121@**3.com",
  29.            "me": true,
  30.            "permissionId": "239046878371512704"
  31.        }
  32.    ],
  33.    "lastEditor": {
  34.        "category": "drive#user",
  35.        "displayName": "*******3121@**3.com",
  36.        "me": true,
  37.        "permissionId": "239046878371512704"
  38.    },
  39.    "hasShared": false,
  40.    "ownedByMe": true,
  41.    "capabilities": {
  42.        "addChildNodePermission": false,
  43.        "writerHasChangeCopyPermission": false,
  44.        "commentPermission": true,
  45.        "copyPermission": true,
  46.        "deletePermission": true,
  47.        "downloadPermission": true,
  48.        "editPermission": true,
  49.        "listChildNodePermission": false,
  50.        "editContentPermission": true,
  51.        "readHistoryVersionPermission": true,
  52.        "removeChildNodePermission": false,
  53.        "renameFilePermission": true,
  54.        "shareFilePermission": true,
  55.        "recyclePermission": true,
  56.        "unrecyclePermission": true
  57.    },
  58.    "permissions": [
  59.        {
  60.            "category": "drive#permission",
  61.            "id": "239046878371512704",
  62.            "type": "user",
  63.            "role": "owner",
  64.            "displayName": "*******3121@**3.com",
  65.            "allowFileDiscovery": true,
  66.            "deleted": false
  67.        }
  68.    ],
  69.    "permissionIds": [
  70.        "239046878371512704"
  71.    ],
  72.    "size": 8023,
  73.    "occupiedSpace": 8023,
  74.    "pictureMetadata": {
  75.        "width": 300,
  76.        "height": 168
  77.    },
  78.    "sha256": "39c55b9e08d47ac119dc8cbcb82196d827cd9a7f72ea376e6570478fca547782",
  79.    "contentVersion": "32ee3e6b-a056-33a9-8131-160bfbd97d9b"
  80. }

4.9 Updating a File

Introduction

Moves a file to the recycle bin, restores a file from the recycle bin, moves a file to another location, and updates file metadata using the Files.update API.

Restrictions

1. The fields parameter is optional. Its value must comply with the format requirements of a partial response.

2. The file name cannot be changed for a file moved to the recycle bin.

3. The thumbnail of a file must be updated along with the file.

4. The MIME type of a folder cannot be modified.

5. addParentFolder and removeParentFolder must be both set or left empty.

6. appSettings, properties, and other parameters whose values are an array of key-value pairs: The value can consist of up to 30 key-value pairs (each file can have at most 30 public custom attributes and 30 private custom attributes). In each key-value pair, both the key and value must not exceed 124 bytes. The key can only be of the string type, while the value can only be of the primitive type.

7. Time parameters must comply with the RFC3339 format requirements.

8. fileName: The value can consist of up to 80 bytes.

9. File names or subfolder names in a folder must be unique.

10. A file cannot be changed to a folder, and vice versa.

11. A file's metadata will not be updated if only the recycled field is passed or no field is passed.

12. A file is restored only when it is in the recycle bin and the value of recycled is false.

13. The file name does not support emoji and invalid characters such as angle brackets (<>), vertical lines (|), colons (:), quotation marks ("), asterisks (*), question marks (?), forward slashes (/), and back slashes (\).

14. Currently, the form parameter has a fixed value of json. If the parameter is left empty, json is used by default.

15. Files cannot be moved between Drive and app folders.

16. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive.metadata

17. If the parent folder or subfolder of a file or folder of the current user contains a folder created by a different user with the owner permission, the file or folder of the current user cannot be deleted. To delete the file or folder of the current user, first delete the folder of another user.

Sending a Request to Update a File

Step 1 Create a PATCH request to the Files.update API.

Step 2 Set the query parameters {fileId} and fields=*.

Example:

  1. PATCH https://drive.cloud.hicloud.com/drive/v1/files/{fileId}?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. PATCH https://drive.cloud.hicloud.com/drive/v1/files/DSQpEkxcAAADKXEPJAYABgOUVrNwA8Cu?fields=* HTTP/1.1
  2. Accept:application/json
  3. Content-Type: application/json
  4. Cache-Control: no-cache
  5. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  6. Cache-Control: no-cache


  7. {
  8.    "favorite":false,
  9.    "fileName":"HuaweiTest22",
  10.    "recycled":false,
  11.    "description":"update file info test testinfooooooooooootttttt",
  12.    "originalFilename":"ori",
  13.    "writerHasCopyPermission":false,
  14.    "writersHasSharePermission":false,
  15.    "properties":{
  16.        "k1":"v1",
  17.        "k2":"v2",
  18.        "k3":"v3"
  19.    },
  20.    "appSettings":{
  21.        "k1":"v1",
  22.        "k2":"v2",
  23.        "k3":"v3"
  24.    }
  25. }

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "fileName": "HuaweiTest02",
  4.    "sha256": "86041fa5f0e85ac7681191eda329527af803fa8f3b512896746e60436c496698",
  5.    "description": "update file info",
  6.    "owners": [
  7.        {
  8.            "permissionId": "239046878371512704",
  9.            "displayName": "*******3121@**3.com",
  10.            "me": true,
  11.            "category": "drive#user"
  12.        }
  13.    ],
  14.    "mimeType": "text/plain;charset=UTF-8",
  15.    "permissionIds": [
  16.        "239046878371512704"
  17.    ],
  18.    "lastHistoryVersionId": "ABwJbYrUCuoCKUxk8OFP43gRTGLw7ArsA",
  19.    "parentFolder": [
  20.        "AgFovWXIAIYANC20H_1Fj3oMLbIf8ACAA"
  21.    ],
  22.    "recycled": false,
  23.    "directlyRecycled": false,
  24.    "permissions": [
  25.        {
  26.            "canDiscoverFile": true,
  27.            "role": "owner",
  28.            "displayName": "*******3121@**3.com",
  29.            "id": "239046878371512704",
  30.            "category": "drive#permission",
  31.            "type": "user"
  32.        }
  33.    ],
  34.    "occupiedSpace": 3748,
  35.    "createdTime": "2020-03-05T14:07:47.000Z",
  36.    "id": "DSQpEkxcAAADKXEPJAYABgOUVrNwA8Cu",
  37.    "contentDownloadLink": "https://lfstoragesecureVFS01.hwcloudtest.cn:18843/drive/v1/files/ABwJbYrUCuoCKUxk8OFP43gRTGLw7ArsA?form=content",
  38.    "smallThumbnailDownloadLink": "https://lfstoragesecureVFS01.hwcloudtest.cn:18843/drive/v1/smallThumbnails/ABwJbYrUCuoCKUxk8OFP43gRTGLw7ArsA?form=content",
  39.    "capabilities": {
  40.        "renameFilePermission": true,
  41.        "downloadPermission": true,
  42.        "commentPermission": true,
  43.        "deletePermission": true,
  44.        "readHistoryVersionPermission": true,
  45.        "recyclePermission": true,
  46.        "addChildNodePermission": false,
  47.        "unrecyclePermission": true,
  48.        "writerHasChangeCopyPermission": false,
  49.        "editContentPermission": true,
  50.        "copyPermission": true,
  51.        "removeChildNodePermission": false,
  52.        "editPermission": true,
  53.        "shareFilePermission": true,
  54.        "listChildNodePermission": false
  55.    },
  56.    "ownedByMe": true,
  57.    "thumbnailDownloadLink": "https://lfstoragesecureVFS01.hwcloudtest.cn:18843/drive/v1/thumbnails/ABwJbYrUCuoCKUxk8OFP43gRTGLw7ArsA?form=content",
  58.    "version": 1584694471000,
  59.    "pictureMetadata": {
  60.        "width": 306,
  61.        "height": 165
  62.    },
  63.    "appSettings": {
  64.        "k1": "v1",
  65.        "k2": "v2",
  66.        "k3": "v3"
  67.    },
  68.    "writersHasSharePermission": false,
  69.    "editedTime": "2020-03-05T14:07:47.000Z",
  70.    "iconDownloadLink": "https://event-dre.dbankcdn.com/filemanagerpic/201911140913476Sc7.png",
  71.    "size": 3748,
  72.    "thumbnailVersion": 0,
  73.    "writerHasCopyPermission": false,
  74.    "lastEditor": {
  75.        "permissionId": "239046878371512704",
  76.        "displayName": "*******3121@**3.com",
  77.        "me": true,
  78.        "category": "drive#user"
  79.    },
  80.    "existThumbnail": true,
  81.    "containers": [
  82.        "drive"
  83.    ],
  84.    "category": "drive#file",
  85.    "favorite": false,
  86.    "contentVersion": "916481f1-8d1c-3cf3-9975-316c6f0c8423",
  87.    "properties": {
  88.        "k1": "v1",
  89.        "k2": "v2",
  90.        "k3": "v3"
  91.    },
  92.    "originalFilename": "ori"
  93. }

4.10 Copying a File

Introduction

Copies a file to the designated folder using the Files.copy API, including modifying the file attributes such as renaming the file when copying it to the destination folder.

Restrictions

1. The fields parameter is optional. Its value must comply with the format requirements of a partial response.

2. Only files can be copied. Folders cannot be copied.

3. appSettings, properties, and other parameters whose values are an array of key-value pairs: The value can consist of up to 30 key-value pairs. In each key-value pair, both the key and value must not exceed 124 bytes. The key can only be of the string type, while the value can only be of the primitive type.

4. Time parameters must comply with the RFC3339 format requirements.

5. The folder name can contain a maximum of 80 characters.

6. If parentFolder contains multiple parent folder IDs, the first ID will be used by default. If parentFolder is left empty, the file will be copied to the root directory of Drive.

7. The file name or subfolder name in a folder must be unique.

8. The file name or description does not support emoji.

9. Currently, the form parameter has a fixed value of json. If the parameter is left empty, json is used by default.

10. Files cannot be copied between Drive and app folders.

11. The scope value must be one of the following:

      https://www.huawei.com/auth/drive.file

      https://www.huawei.com/auth/drive

      https://www.huawei.com/auth/drive.appdata

Sending a Request to Copy a File

Step 1 Create a POST request to the Files.copy API.

Step 2 Set the query parameters fileds=* and fileId={fileId}.

Example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/copy?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/files/DSQpEkxcAAADKXEPJAYABgOUVrNwA8Cu/copy?fields=* HTTP/1.1
  2. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  3. Cache-Control: no-cache
  4. Accept:application/json
  5. {
  6.         "mimeType": "text/plain;charset=UTF-8",
  7.         "fileName": "HWTest001"
  8. }

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "fileName": "HWTest001",
  4.    "sha256": "86041fa5f0e85ac7681191eda329527af803fa8f3b512896746e60436c496698",
  5.    "owners": [
  6.        {
  7.            "permissionId": "239046878371512704",
  8.            "displayName": "*******3121@**3.com",
  9.            "me": true,
  10.            "category": "drive#user"
  11.        }
  12.    ],
  13.    "hasShared": false,
  14.    "mimeType": "text/plain;charset=UTF-8",
  15.    "permissionIds": [
  16.        "239046878371512704"
  17.    ],
  18.    "lastHistoryVersionId": "ABwJbYrUCuoCKUxk8OFP43gRTGLw7ArsA",
  19.    "parentFolder": [
  20.        "AgFovWXIAIYANC20H_1Fj3oMLbIf8ACAA"
  21.    ],
  22.    "recycled": false,
  23.    "directlyRecycled": false,
  24.    "permissions": [
  25.        {
  26.            "canDiscoverFile": true,
  27.            "role": "owner",
  28.            "displayName": "*******3121@**3.com",
  29.            "id": "239046878371512704",
  30.            "category": "drive#permission",
  31.            "type": "user"
  32.        }
  33.    ],
  34.    "occupiedSpace": 3748,
  35.    "createdTime": "2020-03-05T14:07:47.000Z",
  36.    "id": "ABwJbYrUCuoCKUxk8OFP43gRTGLw7ArsA",
  37.    "contentDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/files/ABwJbYrUCuoCKUxk8OFP43gRTGLw7ArsA?form=content",
  38.    "smallThumbnailDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/smallThumbnails/ABwJbYrUCuoCKUxk8OFP43gRTGLw7ArsA?form=content",
  39.    "capabilities": {
  40.        "renameFilePermission": true,
  41.        "downloadPermission": true,
  42.        "commentPermission": true,
  43.        "deletePermission": true,
  44.        "readHistoryVersionPermission": true,
  45.        "recyclePermission": true,
  46.        "addChildNodePermission": false,
  47.        "unrecyclePermission": true,
  48.        "writerHasChangeCopyPermission": false,
  49.        "editContentPermission": true,
  50.        "copyPermission": true,
  51.        "removeChildNodePermission": false,
  52.        "editPermission": true,
  53.        "shareFilePermission": true,
  54.        "listChildNodePermission": false
  55.    },
  56.    "ownedByMe": true,
  57.    "thumbnailDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/thumbnails/ABwJbYrUCuoCKUxk8OFP43gRTGLw7ArsA?form=content",
  58.    "pictureMetadata": {
  59.        "width": 306,
  60.        "height": 165
  61.    },
  62.    "editedTime": "2020-03-05T14:07:47.000Z",
  63.    "iconDownloadLink": "https://event-dre.dbankcdn.com/filemanagerpic/201911140913476Sc7.png",
  64.    "size": 3748,
  65.    "thumbnailVersion": 0,
  66.    "writerHasCopyPermission": false,
  67.    "lastEditor": {
  68.        "permissionId": "239046878371512704",
  69.        "displayName": "*******3121@**3.com",
  70.        "me": true,
  71.        "category": "drive#user"
  72.    },
  73.    "existThumbnail": true,
  74.    "containers": [
  75.        "drive"
  76.    ],
  77.    "category": "drive#file",
  78.    "favorite": false,
  79.    "contentVersion": "916481f1-8d1c-3cf3-9975-316c6f0c8423"
  80. }

4.11 Uploading a File (Multipart Mode)

Introduction

Uploads a file along with its metadata (up to 20 MB in total) using the Files.create.multipart API.

Restrictions

1. Mandatory parameter: uploadType, whose value must be multipart.

2. The fields parameter is optional. Its value must comply with the format requirements of a partial response.

3. The scope value must be one of the following:

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive.appfile

4. The request body must comply with the format requirements of the multipart method and should consist of the file metadata and the binary file content.

5. appSettings: The value can consist of up to 30 key-value pairs.

6. The file to be uploaded cannot exceed 20 MB.

7. All time parameters must comply with the RFC 3339 format requirements.

8. description: The value can neither contain emoji nor exceed 512 bytes.

9. fileName and originalFilename: The value can consist of up to 80 bytes, without supporting emoji and special characters including, angle brackets (<>), vertical lines (|), colons (:), quotation marks ("), asterisks (*), question marks (?), forward slashes (/), and back slashes (\).

10. parentFolder: The value cannot contain two consecutive dots (..).

11. properties: The value can consist of up to 30 key-value pairs. In each key-value pair, both the key and value must not exceed 124 bytes.

12. sha256: The value must be a string of 64 bytes and comply with the SHA-256 algorithm format requirements.

13. contentExtras: This parameter can be left empty. If it is set, the thumbnail content must be encoded using Base64 and cannot exceed 2 MB.If it is set to an invalid value, it will be ignored. In this case, a default thumbnail will be generated based on the supported file type.

14. mimeType: Its value comply with the general format requirements.

15. The value of Content-Type must be multipart/related.

16. A zero-byte file cannot be uploaded.

Note

1. Use the Files.create.resume API to upload a file larger than 20 MB.

Sending a Request to Upload a File

Step 1 Create a POST request to the Files.create.multipart API.

Step 2 Set the query parameters uploadType=multipart and fields=*.

Example:

  1. POST https://drive.cloud.hicloud.com/upload/drive/v1/files?uploadType=multipart&fields=*

Step 3 Set HTTP header fields.

Content-Type: media type of the file to be uploaded

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Set the request body.

Step 5 Send the request.

Request example:

  1. POST https://drive.cloud.hicloud.com/upload/drive/v1/files?uploadType=multipart&fields=* HTTP/1.1
  2. Content-Type: multipart/related;boundary=OP8XTaXZ0UZs-Sjlefcj2OWskqXWwVQO
  3. Cache-Control: no-cache
  4. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  5. --OP8XTaXZ0UZs-Sjlefcj2OWskqXWwVQO
  6. Content-Type: application/json
  7. //Line break is required
  8. {
  9.            "fileName":"zztest0014",
  10.            "contentExtras": {
  11.                "thumbnail":{
  12.                    "content":"dGVzdDAwMw==",
  13.                    "mimeType":"image/png"
  14.                }
  15.            },
  16.            "parentFloder":["applicationData"]
  17. }
  18. --OP8XTaXZ0UZs-Sjlefcj2OWskqXWwVQO
  19. Content-Type: application/octet-stream
  20. //Line break is required
  21. [imageData]
  22. --OP8XTaXZ0UZs-Sjlefcj2OWskqXWwVQO--

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "category": "drive#file",
  4.    "id": "AB9FPewYCuoCKgA0li1P43gSADKWIArsA",
  5.    "fileName": "zztest0014",
  6.    "mimeType": "application/octet-stream",
  7.    "favorite": false,
  8.    "recycled": false,
  9.    "directlyRecycled": false,
  10.    "parentFolder": [
  11.        "AgFovWXIAIYANC20H_1Fj3oMLbIf8ACAA"
  12.    ],
  13.    "containers": [
  14.        "MyDrive"
  15.    ],
  16.    "version": 1584928312000,
  17.    "contentDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/files/AB9FPewYCuoCKgA0li1P43gSADKWIArsA?form=content",
  18.    "iconDownloadLink": "https://event-dre.dbankcdn.com/filemanagerpic/201911140913476Sc7.png",
  19.    "existThumbnail": false,
  20.    "thumbnailVersion": 0,
  21.    "createdTime": "2020-03-23T01:52:43.000Z",
  22.    "editedTime": "2020-03-23T01:52:43.000Z",
  23.    "owners": [
  24.        {
  25.            "category": "drive#user",
  26.            "displayName": "*******3121@**3.com",
  27.            "me": true,
  28.            "permissionId": "239046878371512704"
  29.        }
  30.    ],
  31.    "lastEditor": {
  32.        "category": "drive#user",
  33.        "displayName": "*******3121@**3.com",
  34.        "me": true,
  35.        "permissionId": "239046878371512704"
  36.    },
  37.    "hasShared": false,
  38.    "ownedByMe": true,
  39.    "capabilities": {
  40.        "addChildNodePermission": false,
  41.        "writerHasChangeCopyPermission": false,
  42.        "commentPermission": true,
  43.        "copyPermission": true,
  44.        "deletePermission": true,
  45.        "downloadPermission": true,
  46.        "editPermission": true,
  47.        "listChildNodePermission": false,
  48.        "editContentPermission": true,
  49.        "readHistoryVersionPermission": true,
  50.        "removeChildNodePermission": false,
  51.        "renameFilePermission": true,
  52.        "shareFilePermission": true,
  53.        "recyclePermission": true,
  54.        "unrecyclePermission": true
  55.    },
  56.    "permissions": [
  57.        {
  58.            "category": "drive#permission",
  59.            "id": "239046878371512704",
  60.            "type": "user",
  61.            "role": "owner",
  62.            "displayName": "*******3121@**3.com",
  63.            "allowFileDiscovery": true,
  64.            "deleted": false
  65.        }
  66.    ],
  67.    "permissionIds": [
  68.        "239046878371512704"
  69.    ],
  70.    "size": 7960,
  71.    "occupiedSpace": 7960,
  72.    "sha256": "cb823658e6d43cac59621523e9c7ed6e9d1c37f1fb6877174cfbb50cd21308d0",
  73.    "contentVersion": "54d53a55-f67e-3f5c-9c08-043752835352"
  74. }

4.12 Resuming File Upload

Introduction

Resumes the upload of a large file using the Files.resume API, including obtaining the resumable session URI of the current file from the location parameter returned by the Files.create.resume or Files.update.resume API and uploading new file parts based on the resumable session URI.

Restrictions

1. Mandatory parameter: uploadId

2. A file of up to 64 MB can be uploaded each time.

3. uploadId: Specifies the ID of the resumable session that is requested.

4. uploadType=resume: The value must be resume, indicating a resumable upload.

5. Content-Length: Its value must be the same as the content length included in the request body. When it is set to 0, the resumable session information will be queried by default.

6. Content-Range: Its value is in the format of "bytes start-end/totalFileSize", where: start indicates the start location of the content being uploaded in contrast to the file, while end indicates the end location of the content, and totalFileSize indicates the file size obtained using the Files.create.resume API. The value of "end-start + 1" should be equal to the value of Content-Length.

7. The scope value must be one of the following:

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive.file

8. content-Type: Its value comply with the general format requirements.

9. A zero-byte file cannot be uploaded.

Note

1.The result code 308 indicates the location at which you should continue to upload the file, 200/201 indicates that the upload is complete, and 404 indicates that the current location information is invalid and the upload needs to be restarted from calling the Files.create.resume API.

2. To obtain the file metadata, you need to call the Files.resume API again after the last file upload session is successful. For example, to upload a file smaller than 64 MB and obtain its metadata, you need to call the API twice.

Sending a Request to Resume File Upload

Step 1 Create a PUT request to the Files.resume API.

Step 2 Set the query parameters {serverId}, uploadType=resume, and {uploadId}.

Example:

  1. PUT https://drive.cloud.hicloud.com/upload/drive/v1/{serverId}/files?uploadType=resume&uploadId={uploadId}

Step 3 Set the request body.

Add the file data to the request body.

Step 4 Set HTTP header fields.

Content-Range: range of the file to be uploaded, in bytes

Content-Type: type of the file to be uploaded

Content-Length: length of the file to be uploaded

Authorization: authorization code obtained from the HUAWEI Account server

Step 5 Send the request.

Request example:

  1. PUT https://drive.cloud.hicloud.com/upload/drive/v1/b9ZlaRcoLELMLELENoMg/files?uploadType=resume&uploadId=238430073756776448 HTTP/1.1
  2. Content-Type: image/jpeg
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  4. Content-Length: 115085
  5. Content-Range: bytes 0-115084/115085
  6. [imagedata]

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "fileName":"HWTest001",
  4.    "sha256":"39c55b9e08d47ac119dc8cbcb82196d827cd9a7f72ea376e6570478fca547782",
  5.    "owners":[
  6.        {
  7.            "permissionId":"239046878371512704",
  8.            "displayName":"*******3121@**3.com",
  9.            "me":true,
  10.            "category":"drive#user"
  11.        }
  12.    ],
  13.    "hasShared":false,
  14.    "mimeType":"application/octet-stream",
  15.    "permissionIds":[
  16.        "239046878371512704"
  17.    ],
  18.    "parentFolder":[
  19.        "AgFovWXIAIYANC20H_1Fj3oMLbIf8ACAA"
  20.    ],
  21.    "recycled":false,
  22.    "directlyRecycled":false,
  23.    "permissions":[
  24.        {
  25.            "role":"owner",
  26.            "deleted":false,
  27.            "displayName":"*******3121@**3.com",
  28.            "id":"239046878371512704",
  29.            "category":"drive#permission",
  30.            "type":"user",
  31.            "allowFileDiscovery":true
  32.        }
  33.    ],
  34.    "occupiedSpace":8023,
  35.    "createdTime":"2020-03-23T06:09:34.000Z",
  36.    "id":"AB9HB6XUCuoCKgIO3-FP43gSAgjf7ArsA",
  37.    "contentDownloadLink":"https://drive.cloud.hicloud.com/drive/v1/files/AB9HB6XUCuoCKgIO3-FP43gSAgjf7ArsA?form=content",
  38.    "capabilities":{
  39.        "downloadPermission":true,
  40.        "renameFilePermission":true,
  41.        "commentPermission":true,
  42.        "deletePermission":true,
  43.        "readHistoryVersionPermission":true,
  44.        "recyclePermission":true,
  45.        "addChildNodePermission":false,
  46.        "unrecyclePermission":true,
  47.        "writerHasChangeCopyPermission":false,
  48.        "copyPermission":true,
  49.        "editContentPermission":true,
  50.        "removeChildNodePermission":false,
  51.        "editPermission":true,
  52.        "listChildNodePermission":false,
  53.        "shareFilePermission":true
  54.    },
  55.    "ownedByMe":true,
  56.    "version":1584943722000,
  57.    "iconDownloadLink":"https://event-dre.dbankcdn.com/filemanagerpic/201911140913476Sc7.png",
  58.    "editedTime":"2020-03-23T06:09:34.000Z",
  59.    "size":8023,
  60.    "thumbnailVersion":0,
  61.    "lastEditor":{
  62.        "permissionId":"239046878371512704",
  63.        "displayName":"*******3121@**3.com",
  64.        "me":true,
  65.        "category":"drive#user"
  66.    },
  67.    "existThumbnail":false,
  68.    "containers":[
  69.        "MyDrive"
  70.    ],
  71.    "category":"drive#file",
  72.    "favorite":false,
  73.    "contentVersion":"32ee3e6b-a056-33a9-8131-160bfbd97d9b"
  74. }

4.13 Creating a Resumable Upload Request and Preparing for Resumable Upload

Introduction

Initializes the resumable upload task using the Files.create.resume API, including processing the file metadata and obtaining the location information for resumable upload, and saves the related file metadata for use by the Files.resume API.

Restrictions

1. Mandatory parameter: uploadType=resume

2. The request body can only be a JSON string or left empty.

3. All time parameters must comply with the RFC 3339 format requirements.

4. description: The value can neither contain emoji nor exceed 512 bytes.

5. fileName and originalFilename: The value can consist of up to 80 bytes, without supporting emoji and special characters including, angle brackets (<>), vertical lines (|), colons (:), quotation marks ("), asterisks (*), question marks (?), forward slashes (/), and back slashes (\).

6. parentFolder: The value cannot contain two consecutive dots (..).

7. properties: The value can consist of up to 30 key-value pairs. In each key-value pair, both the key and value must not exceed 124 bytes.

8. sha256: The value must be a string of 64 bytes and comply with the SHA-256 algorithm format requirements.

9. contentExtras: This parameter can be left empty. If it is set, the thumbnail content must be encoded using Base64 and cannot exceed 2 MB.If it is set to an invalid value, it will be ignored. In this case, a default thumbnail will be generated based on the supported file type.

10. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive

11. mimeType and content-Type: Their values comply with the general format requirements.

Creating a Resumable Upload Request and Preparing for Resumable Upload

Step 1 Create a POST request to the Files.create.resume API.

Step 2 Set the query parameters uploadType=resume and fields=*.

Example:

  1. POST https://drive.cloud.hicloud.com/upload/drive/v1/files?uploadType=resume&fields=*

Step 3 Set the request body.

Add the file metadata (if any) in JSON format to the request body. Otherwise, leave the request body empty.

Step 4 Set HTTP header fields.

X-Upload-Content-Type: Optional. Set to the media type of the file data to be transferred. If the media type is not specified in metadata or through this header, it will be set to application/octet-stream by default.

X-Upload-Content-Length: length of the file to be uploaded

Content-Type: type of the file to be uploaded

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 5 Send the request.

Request example:

  1. POST https://drive.cloud.hicloud.com/upload/drive/v1/files?uploadType=resume&fields=* HTTP/1.1
  2. Content-Type: application/json
  3. X-Upload-Content-Type: image/jpeg
  4. X-Upload-Content-Length: 200000
  5. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  6. Cache-Control: no-cache
  7. {
  8.     "fileName": "HWTest001"
  9. }

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "sliceSize":4194304
  4. }
  5. Headers:
  6. Location:https://drive.cloud.hicloud.com/upload/drive/v1/fc7300dbe0280d39/files?fields=*&uploadType=resume&uploadId=324314495017204480
  7. Content-Type: application/json; charset=utf-8
  8. Content-Length: 21

4.14 Uploading a File (Content Mode)

Introduction

Uploads a file of up to 20 MB and returns the file metadata using the Files.create.content API.

Restrictions

1. Mandatory parameter: uploadType, which must be set to content.

2. The fields parameter is optional. Its value must comply with the format requirements of a partial response.

3. The request body contains the binary content of the file to be uploaded, which must not exceed 20 MB.

4. The scope value must be one of the following:

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive.appfile

5. A zero-byte file cannot be uploaded.

Note

1. Use the Files.create.resume API to upload a file larger than 20 MB.

Sending a Request to Upload a File

Step 1 Create a POST request to the Files.create.content API.

Step 2 Set the query parameters uploadType=content and fields=*.

Example:

  1. POST https://drive.cloud.hicloud.com/upload/drive/v1/files?uploadType=content&fields=*

Step 3 Set the request body.

Add the file data to the request body.

Step 4 Set HTTP header fields.

Content-Type: type of the file to be uploaded

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 5 Send the request.

Request example:

  1. POST https://drive.cloud.hicloud.com/upload/drive/v1/files?uploadType=media&fields=* HTTP/1.1
  2. Content-Type: image/jpeg
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  4. Cache-Control: no-cache
  5. [imageData]

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "category": "drive#file",
  4.    "id": "AB9FfdS4CuoCKgB0ro1P43gSAHKugArsA",
  5.    "fileName": "noname1584930462469",
  6.    "mimeType": "image/jpeg",
  7.    "favorite": false,
  8.    "recycled": false,
  9.    "directlyRecycled": false,
  10.    "parentFolder": [
  11.        "AgFovWXIAIYANC20H_1Fj3oMLbIf8ACAA"
  12.    ],
  13.    "containers": [
  14.        "MyDrive"
  15.    ],
  16.    "version": 1584930412000,
  17.    "contentDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/files/AB9FfdS4CuoCKgB0ro1P43gSAHKugArsA?form=content",
  18.    "iconDownloadLink": "https://event-dre.dbankcdn.com/filemanagerpic/201911140913476Sc7.png",
  19.    "existThumbnail": true,
  20.    "thumbnailDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/thumbnails/AB9FfdS4CuoCKgB0ro1P43gSAHKugArsA?form=content",
  21.    "smallThumbnailDownloadLink": "https://drive.cloud.hicloud.com/drive/v1/smallThumbnails/AB9FfdS4CuoCKgB0ro1P43gSAHKugArsA?form=content",
  22.    "thumbnailVersion": 0,
  23.    "createdTime": "2020-03-23T02:27:44.000Z",
  24.    "editedTime": "2020-03-23T02:27:44.000Z",
  25.    "owners": [
  26.        {
  27.            "category": "drive#user",
  28.            "displayName": "*******3121@**3.com",
  29.            "me": true,
  30.            "permissionId": "239046878371512704"
  31.        }
  32.    ],
  33.    "lastEditor": {
  34.        "category": "drive#user",
  35.        "displayName": "*******3121@**3.com",
  36.        "me": true,
  37.        "permissionId": "239046878371512704"
  38.    },
  39.    "hasShared": false,
  40.    "ownedByMe": true,
  41.    "capabilities": {
  42.        "addChildNodePermission": false,
  43.        "writerHasChangeCopyPermission": false,
  44.        "commentPermission": true,
  45.        "copyPermission": true,
  46.        "deletePermission": true,
  47.        "downloadPermission": true,
  48.        "editPermission": true,
  49.        "listChildNodePermission": false,
  50.        "editContentPermission": true,
  51.        "readHistoryVersionPermission": true,
  52.        "removeChildNodePermission": false,
  53.        "renameFilePermission": true,
  54.        "shareFilePermission": true,
  55.        "recyclePermission": true,
  56.        "unrecyclePermission": true
  57.    },
  58.    "permissions": [
  59.        {
  60.            "category": "drive#permission",
  61.            "id": "239046878371512704",
  62.            "type": "user",
  63.            "role": "owner",
  64.            "displayName": "*******3121@**3.com",
  65.            "allowFileDiscovery": true,
  66.            "deleted": false
  67.        }
  68.    ],
  69.    "permissionIds": [
  70.        "239046878371512704"
  71.    ],
  72.    "size": 47524,
  73.    "occupiedSpace": 47524,
  74.    "pictureMetadata": {
  75.        "width": 600,
  76.        "height": 399
  77.    },
  78.    "sha256": "1362fa09aeb776e2600e3c15942044064b7587ed27301134c6c6a21e7d55c38d",
  79.    "contentVersion": "4995762d-3270-34b0-a062-1055ea3ea5aa"
  80. }

4.15 Creating a File Folder

Introduction

Creates a folder and returns the folder details using the Files.create.metadata API. This API cannot be used to create a file.

Restrictions

1. The fields parameter is optional. Its value must comply with the format requirements of a partial response.

2. Time parameters must comply with the RFC3339 format requirements.

3. mimeType: Its value must be application/vnd.huawei-apps.folder, indicating that only folders are supported.

4. The folder name can contain a maximum of 80 characters.

5. Each folder can have only one parent folder. If parentFolder contains multiple parent folder IDs, the first ID will be used by default. If parentFolder is left empty, the folder will be created in the root directory of Drive.

6. File names or subfolder names in a folder must be unique.

7. The file name or description does not support emoji.

8. appSettings, properties, and other parameters whose values are an array of key-value pairs: The value can consist of up to 30 key-value pairs. In each key-value pair, both the key and value must not exceed 124 bytes. The key can only be of the string type, while the value can only be of the primitive type.

9. Currently, the form parameter has a fixed value of json. If the parameter is left empty, json is used by default.

10. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.readonly

    https://www.huawei.com/auth/drive.metadata

    https://www.huawei.com/auth/drive.metadata.readonly

Sending a Request to Create a Folder

Step 1 Create a POST request to the Files.create.metadata API.

Step 2 Set the response parameter fields=*.

Example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/files?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/files?fields=* HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Cache-Control: no-cache
  5. Authorization: Bearer CF3NTYZSs7MRmxWyj8ssonQQxDgSPAjnDvrf+91NrpN22LdUrMA30A5Kzz0mf55sWao7e7VeLrmjQ0z2OmwPWlt3S00/L1BJppbTFhIgWb74ZBK8CFImUA==


  6. {
  7.            "favorite": "true",
  8.            "fileName": "test1234",
  9.            "description": "folder",
  10.            "mimeType": "application/vnd.huawei-apps.folder" // Support only the creation of a folder.
  11. }

Response example:

If successful, the server returns the HTTP 200 OK status code.

  1. HTTP/1.1 200 OK
  2. {
  3.    "hasShared":false,
  4.    "editedTime":"2019-11-24T19:15:31.000Z",
  5.    "capabilities":{
  6.        "writerHasChangeCopyPermission":false,
  7.        "editPermission":true,
  8.        "shareFilePermission":false,
  9.        "renameFilePermission":true,
  10.        "editContentPermission":true,
  11.        "addChildNodePermission":true,
  12.        "listChildNodePermission":true,
  13.        "recyclePermission":true,
  14.        "removeChildNodePermission":true,
  15.        "copyPermission":true,
  16.        "downloadPermission":true,
  17.        "deletePermission":true,
  18.        "unrecyclePermission":true
  19.    },
  20.    "existThumbnail":false,
  21.    "category":"drive#file",
  22.    "description":"folder",
  23.    "owners":[
  24.        {
  25.            "permissionId":"233222458247741824",
  26.            "category":"drive#user",
  27.            "me":true
  28.        }
  29.    ],
  30.    "mimeType":"application/vnd.huawei-apps.folder",
  31.    "ownedByMe":true,
  32.    "iconDownloadLink":"https://event-dre.dbankcdn.com/filemanagerpic/201911140913476Sc7.png",
  33.    "favorite":true,
  34.    "thumbnailVersion":0,
  35.    "fileName":"zhaiTest-1",
  36.    "containers":[
  37.        "drive"
  38.    ],
  39.    "createdTime":"2019-11-24T19:15:31.000Z",
  40.    "id":"DSQpEkxcAAADKXEPJIYABgNyCpNwANCu",
  41.    "parentFolder":[
  42.        "DSQpEkxcAAADKXEPJIYABgJMDZNQAKDI"
  43.    ]
  44. }

4.16 Retrieving File Metadata

Introduction

Retrieves the metadata of a file using the Files.get API.

Restrictions

1. The fields parameter is optional. Its value must comply with the format requirements of a partial response.

2. Only the reader, writer, commenter, owner role can retrieve a file metadata.

3. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive.metadata

    https://www.huawei.com/auth/drive.readonly

    https://www.huawei.com/auth/drive.metadata.readonly

Sending a Request to Retrieve File Metadata

Step 1 Create a GET request to the Files.get API.

Step 2 Set the query parameters {fileId} and fields=*.

Example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/{fileId}?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/DSQpEkxcAAADKXEPJAYABgOUVrNwA8Cu HTTP/1.1
  2. Content-Type: application/json
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  4. Cache-Control: no-cache

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "hasShared":false,
  4.    "editedTime":"2019-11-25T02:39:34.000Z",
  5.    "writerHasCopyPermission":false,
  6.    "sha256":"dc840240d3f2ac81b08dadf73e5b5f128823fa766f6daf1b3dbc0e03b2635f59",
  7.    "description":"update file info test testinfooooooooooooootttttt",
  8.    "owners":[
  9.        {
  10.            "permissionId":"233222458247741824",
  11.            "category":"drive#user",
  12.            "me":true
  13.        }
  14.    ],
  15.    "mimeType":"application/vnd.huawei11-apps.folder",
  16.    "occupiedSpace":11952640,
  17.    "lastModifyingUser":{
  18.        "permissionId":"233222458247741824",
  19.        "category":"drive#user",
  20.        "me":true
  21.    },
  22.    "iconDownloadLink":"https://event-dre.dbankcdn.com/filemanagerpic/201911140913476Sc7.png",
  23.    "favorite":false,
  24.    "createdTime":"2019-11-25T00:15:13.000Z",
  25.    "id":"DSQpEkxcAAADKXEPJAYABgOUVrNwA8Cu",
  26.    "contentDownloadLink":"https://drive.cloud.hicloud.com/drive/v1/files/DSQpEkxcAAADKXEPJAYABgOUVrNwA8Cu?form=content",
  27.    "writersHasSharePermission":false,
  28.    "capabilities":{
  29.        "writerHasChangeCopyPermission":false,
  30.        "editPermission":true,
  31.        "shareFilePermission":false,
  32.        "renameFilePermission":true,
  33.        "editContentPermission":true,
  34.        "addChildNodePermission":true,
  35.        "listChildNodePermission":true,
  36.        "recyclePermission":true,
  37.        "removeChildNodePermission":true,
  38.        "copyPermission":true,
  39.        "downloadPermission":true,
  40.        "deletePermission":true,
  41.        "unrecyclePermission":true
  42.    },
  43.    "existThumbnail":false,
  44.    "category":"drive#file",
  45.    "ownedByMe":true,
  46.    "version":1191898112,
  47.    "size":11952640,
  48.    "thumbnailVersion":0,
  49.    "fileName":"HuaweiTest22",
  50.    "containers":[
  51.        "drive"
  52.    ],
  53.    "properties":{
  54.        "k1":"v1",
  55.        "k2":"v2",
  56.        "k3":"v3"
  57.    },
  58.    "originalFilename":"ori",
  59.    "recycled":false,
  60.    "appSettings":{
  61.        "k1":"v1",
  62.        "k2":"v2",
  63.        "k3":"v3"
  64.    },
  65.    "parentFolder":[
  66.        "DSQpEkxcAAADKXEPJIYABgJMDZNQAKDI"
  67.    ]
  68. }

4.17 Downloading a File Content

Introduction

Downloads file content (identified by Range) using the File.get.content API.

Restrictions

1. Mandatory parameter: fileId

2. Range: The value is in "bytes=start-end" format.

3. Currently, the form parameter has a fixed value of content. If the parameter is left empty, an error will be reported.

4. Only file content can be downloaded. Metadata and folders cannot be downloaded.

5. File content can be downloaded by the file owner and a user to whom the file has been shared.

6. The scope value must be one of the following:

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive.readonly

    https://www.huawei.com/auth/drive.appdata

Sending a Request to Download File Content

Step 1 Create a GET request to the Files.get.content API.

Step 2 Set the query parameters {fileId} and fields=*.

Example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/{fileId}?form=content

Step 3 Set HTTP header fields.

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/DSQpEkxcAAADKXEPJAYABgEZivNwAmCu?form=content HTTP/1.1
  2. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk

Response example:

  1. HTTP/1.1 200 OK
  2. [imageData]

4.18 Downloading a Large Thumbnail

Introduction

Downloads the large thumbnail of a file (identified by fileId) using the Thumbnail.get API.

Restrictions

1. Mandatory parameter: fileId

2. Currently, the form parameter has a fixed value of content. If the parameter is left empty, an error will be reported.

3. Only a large thumbnail can be downloaded.

4. The thumbnail can be downloaded by the file owner and a user to whom the file has been shared.

5. The scope value must be one of the following:

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive.readonly

    https://www.huawei.com/auth/drive.appdata

Sending a Request to Download a Large Thumbnail

Step 1 Create a GET request to the Thumbnail.get API.

Step 2 Set the query parameters {fileId} and fields=*.

Example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/thumbnails/{fileId}?form=content

Step 3 Set HTTP header fields.

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/thumbnails/DSQpEkxcAAADKXEPJAYABgEZivNwAmCu?form=content HTTP/1.1
  2. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk

Response example:

  1. HTTP/1.1 200 OK
  2. [imageData]

4.19 Downloading a Small Thumbnail

Introduction

Downloads the small thumbnail of a file (identified byfileId) using the SmallThumbnail.getAPI.

Restrictions

1.Mandatory parameter:fileId

2.Currently, the form parameter has a fixed value of content. If the parameter is left empty, an error will be reported.

3.Only a large thumbnail can be downloaded.

4.The thumbnail can be downloaded by the file owner and a user to whom the file has been shared.

5.The scope value must be one of the following:

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive.readonly

    https://www.huawei.com/auth/drive.appdata

Sending a Request to Download a Large Thumbnail

Step 1 Create aGETrequest to the SmallThumbnail.get API.

Step 2 Set the query parameters {fileId} and fields=*.

Example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/smallThumbnails/{fileId}?form=content

Step 3 Set HTTP header fields.

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/smallThumbnails/DSQpEkxcAAADKXEPJAYABgEZivNwAmCu?form=content HTTP/1.1
  2. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk

Response example:

  1. HTTP/1.1 200 OK
  2. [imageData]

5 Enabling File Change Notification

5.1 Use Case

HUAWEI Drive Kit enables your app to send file change notifications to users, thereby keeping files in the cloud and those stored locally to be in sync. To use the Changes API, your server should be able to receive changes and push them to your app in real time. After receiving the changes, the app can update local files promptly.

5.2 Sending a Simple Request to Enable File Change Notification

Step 1 Register your server URL with Drive, which will check the validity of the address before sending a file change notification.

Sign in to AppGallery Connect and register your server domain name with Drive, as shown in the figure below.

Step 2 Parse the file change notification sent by Drive. The header of the notification adopts the following format:

Parameter

Type

Mandatory/Optional

Description

X-HW-Channel-ID

varchar(255)

Mandatory

Unique user ID that you defined, which is   sent to the Drive server through the Changes.subscribe   API.

X-HW-Channel-Token

varchar(255)

Optional

User token that you defined, which is contained in the request for calling the Changes.subscribe API and will be verified by your server.

X-HW-Channel-Expiration

varchar(255)

Optional

Date and time when the notification   channel expires.

Format: Tue, 18 Jun 2019 14:21:46 GMT.

X-HW-Resource-ID

varchar(255)

Mandatory

Resource ID, which identifies the resource being tracked on this channel.When the resource changes, a notification will be sent.

X-HW-Resource-URI

varchar(255)

Mandatory

Version-specific identifier for the   resource.

X-HW-Resource-State

varchar(255)

Mandatory

Resource state. Values:

sync: The subscription is successful and   the channel is created successfully.

add: The resource is added.

remove: The resource has been deleted.

update: Resource properties have updated.

recycle: The resource has been moved to recycle.

unrecycle: The resource is restored from recycle.

change: The resource has changed.

X-HW-Message-Number

varchar(255)

Mandatory

Message number. A later message number is   always greater than an earlier one, but the numbers may not be consecutive.   The number of a sync message is always 1.

X-HW-Changed

varchar(255)

Optional

File change details. This parameter is   valid only when the value of State is update.

content: Resource content has updated.

properties: Resource properties have updated.

parents: The parent folder of the   resource has changed. Currently this value is not used.

children: Sub-files of the resource have   changed.

 

Step 3 Send the change notification to the app.

Your server sends the change notification to your app, requesting the app to implement the change. Drive does not limit how your server delivers the change notification. However, we recommend that you use the HUAWEI Push service, which enables your server to deliver notifications to designated apps. To use the HUAWEI Push service, you will need to integrate the HMS Core Push SDK ("Push SDK") into your app. For details, please refer to HUAWEI Push Service Introduction. If you do not use the HUAWEI Push service, ensure that your server implements the push function.

Step 4 Configure your server to obtain startCursor and subscribe to the file change notification function through the Changes.subscribe API.

Configure your app calls the Changes.getStartCursor API to obtain the cursor value required by Changes.subscribe API, and then calls the Changes.subscribe API to subscribe to the file changes notification function. The Changes.subscribe API will return the subscribed Channel object and your app needs to pass the userToken in the Channel object on to your server, for authenticating subsequent messages returned. In addition, you can also configure your app can perform desired operations such as updating changes and stopping file change notification based on the Channel object.

Introduction

Tracks changes made to all files or folders of a user using the Changes.subscribe API.

Restrictions

1. Mandatory parameters: fileId, cursor, id, type, and url

2. URL parameters are controlled by a whitelist, namely, only URLs in the whitelist are allowed.

3. type: Currently, its value is web_hook.

4. expirationTime: Its value is expressed as a Unix timestamp.

5. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive. readonly

    https://www.huawei.com/auth/drive. metadata

    https://www.huawei.com/auth/drive. metadata.readonly

Example of request for obtaining startCursor:

  1. GET  https://drive.cloud.hicloud.com/drive/v1/changes/getStartCursor?fields=*    HTTP/1.1
  2. Content-Type: application/json
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  4. Cache-Control: no-cache

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.            "category": "drive#startCursor",
  4.            "startCursor": "238247332125117440"
  5. }

Example of request for calling the Changes.subscribe API:

  1. POST  https://drive.cloud.hicloud.com/drive/v1/changes/subscribe?cursor=238247332125117440&fields=*   HTTP/1.1
  2. Content-Type: application/json
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  4. Cache-Control: no-cache


  5. {
  6.            "url": "https://www.huawei.com",
  7.            "expirationTime": "1574674540000",//Set this parameter to zero to seven days from the current time, expressed as a Unix timestamp. If the parameter is left empty, one hour will be used by default.
  8.            "id": "46TMU",
  9.            "type": "web_hook",
  10.            "userToken": "Qeqqn"
  11. }

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.            "resourceId": "MTIzMzIyMjQ1ODI0Nzc0MTgyNA",
  4.            "category": "api#channel",
  5.            "expirationTime": 1574674540000,
  6.            "id": "46TMU",
  7.            "resourceUri": "https://drive.hicloud.com/drive/v1/changes?pageSize=10&cursor=238247332125117440&form=json",
  8.            "userToken": "Qeqqn"
  9. }

Step 5 Retrieve file changes.

After receiving the notification, the app calls the Changes.list API to retrieve user file changes. Note that the input parameter cursor is the cursor parameter transferred when the Changes.subscribe API was called.

Example of request for calling the Changes.list API:

  1. GET  https://drive.cloud.hicloud.com/drive/v1/changes?cursor=238247332125117440&fields=*   HTTP/1.1
  2. Content-Type: application/json
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  4. Cache-Control: no-cache 

Response example:

  1. HTTP/1.1 200 OK
  2. {
  3.    "category":"drive#changeList",
  4.    "changes":[
  5.        {
  6.            "file":{
  7.                "hasShared":false,
  8.                "editedTime":"2019-11-25T01:16:26.000Z",
  9.                "writerHasCopyPermission":false,
  10.                "sha256":"88513e82e6163b70e28245dab2336e3a8dadca74ff2a65d16725709359055f96",
  11.                "owners":[
  12.                    {
  13.                        "category":"drive#user",
  14.                        "me":true
  15.                    }
  16.                ],
  17.                "mimeType":"image/jpeg",
  18.                "thumbnailDownloadLink":"https://drive.cloud.hicloud.com/drive/v1/thumbnails/b/DSQpEkxcAAADKXEPJAYABgObWANwAoCu?form=content",
  19.                "occupiedSpace":2398864,
  20.                "favorite":false,
  21.                "fileSuffix":"jpg8e578e4ed8974a5b851ecd79f08d7b69",
  22.                "createdTime":"2019-11-25T01:16:26.000Z",
  23.                "fullFileSuffix":"jpg8e578e4ed8974a5b851ecd79f08d7b69",
  24.                "id":"DSQpEkxcAAADKXEPJAYABgObWANwAoCu",
  25.                "contentDownloadLink":"https://drive.cloud.hicloud.com/drive/v1/files/DSQpEkxcAAADKXEPJAYABgObWANwAoCu?form=content",
  26.                "writersHasSharePermission":false,
  27.                "capabilities":{
  28.                    "writerHasChangeCopyPermission":false,
  29.                    "editPermission":true,
  30.                    "shareFilePermission":false,
  31.                    "renameFilePermission":true,
  32.                    "editContentPermission":true,
  33.                    "addChildNodePermission":true,
  34.                    "listChildNodePermission":true,
  35.                    "recyclePermission":true,
  36.                    "removeChildNodePermission":true,
  37.                    "copyPermission":true,
  38.                    "downloadPermission":true,
  39.                    "deletePermission":true,
  40.                    "unrecyclePermission":true
  41.                },
  42.                "existThumbnail":true,
  43.                "category":"drive#file",
  44.                "ownedByMe":true,
  45.                "version":0,
  46.                "size":2398864,
  47.                "thumbnailVersion":0,
  48.                "fileName":"IMG_20191125_171146.jpg8e578e4ed8974a5b851ecd79f08d7b69",
  49.                "pictureMetadata":{
  50.                    "aperture":0,
  51.                    "exposureTime":0,
  52.                    "flashUsed":false,
  53.                    "subjectDistance":0,
  54.                    "rotation":0,
  55.                    "width":384,
  56.                    "isoSpeed":0,
  57.                    "maxApertureValue":0,
  58.                    "exposureBias":0,
  59.                    "height":512,
  60.                    "focalLength":0
  61.                },
  62.                "containers":[
  63.                    "applicationData"
  64.                ],
  65.                "properties":{
  66.                    "appId":"101207111"
  67.                },
  68.                "parentFolder":[
  69.                    "DSQpEkxcAAADKXEPJIYABgJNrnNwAWiu"
  70.                ]
  71.            },
  72.            "category":"drive#change",
  73.            "changeType":"file",
  74.            "time":"2019-11-25T09:15:42.822Z",
  75.            "fileId":"DSQpEkxcAAADKXEPJAYABgObWANwAoCu"
  76.        }
  77.    ],
  78.    "newStartCursor":"238251227308133376"
  79. }

6 Stopping File Change Notification

6.1 Use Case

HUAWEI Drive Kit allows your app to stop sending file change notifications through the designated channel. Then, the channel will not receive file change notifications anymore. Note that the id and resourceId in the constructed Channel object must be the same as those in the Channel object subscribed through the Changes.subscribe API.

6.2 Stopping File Change Notification

Introduction

Stops file change notification on a channel using the channels.stop API.

Restrictions

1. Mandatory parameters: id and resourceId

2. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.appdata

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.readonly

    https://www.huawei.com/auth/drive.metadata

    https://www.huawei.com/auth/drive.metadata.readonly

Sending a Request to Stop File Change Notification

Step 1 Create a POST request to the Channels.stop API.

Step 2 Set the query parameter fields=*.

Example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/channels/stop

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/channels/stop HTTP/1.1
  2. Content-Type: application/json
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk
  4. Cache-Control: no-cache


  5. {
  6.            "category": "api#channel",
  7.            "id": "46TMU",
  8.            "resourceId": "MTIzMzIyMjQ1ODI0Nzc0MTgyNA",
  9.            "resourceUri": "https://drive.hicloud.com/drive/v1/changes?pageSize=10&cursor=238247332125117440&form=json",
  10.            "userToken": "Qeqqn",
  11.            "expirationTime": "1574674540000",
  12.            "type": "web_hook",
  13.            "url": "https://www.huawei.com"
  14. }

Response example:

  1. HTTP/1.1 204 OK


7 Commenting on Files

7.1 Use Case

HUAWEI Drive Kit allows your app to provide file commenting services for users, including commenting on files in the cloud as well as viewing, updating, and deleting comments.

7.2 Creating a Comment

Introduction

Creates a comment on a file using the Commnets.create API.

Restrictions

1. Mandatory parameters: fileId and fields

2. description: It is mandatory but can be left empty, namely, description="". Its value can consist of up to 1024 bytes.

3. quotedContent is optional. In this parameter, mimeType comes with a default value. If quotedContent is left empty, mimeType will not be used. If quotedContent is set, the value of mimeType will always be html/text, regardless of whether it is set to a special character or any other value, and no error will be reported in this case. content can be left empty. Its value can consist of up to 1024 bytes.

4. In position, revision and region are mandatory. The value of revision can consist of 1 to 64 characters and must comply with the regular expression pattern [a-zA-Z0-9_\-]. region can be left empty, namely, in the format of "position":"{'revision':'88-0','region':[]}". The value of rect, a region classifier, can be of the integer or double type, rather than the string type. Currently, its value is of the double type. If a region property, for example, x is missing, the region value, for example, "position":"{'revision':'88-0','region':[{rect:{y:2,w:3,h:4,maxw:3,maxh:5,rotation:8}}]}" is also allowed.

5. By default, a maximum of 100 comments can be created for a file.

6. Only the writer, commenter, or owner role can create a comment.

7. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

Sending a Request to Create a Comment on a File

Step 1 Create a POST request to the Comments.create API.

Step 2 Set the query parameters {fileId} and fields=*.

Example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/comments?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments?fields=* HTTP/1.1  
  2. Accept: application/json  
  3. Content-Type: application/x-www-form-urlencoded  
  4. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk  
  5. Cache-Control: no-cache  
  6. {  
  7.    "description":"2020/02/17 11:20",
  8.    "quotedContent":{"mimeType":"text/html","content":"222222"},
  9.    "position":"{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':'10'}}]}"
  10. }

Response example:

  1. HTTP/1.1 200 OK  
  2. {  
  3.    "creator": {
  4.        "permissionId": "299639512454136576",
  5.        "displayName": "*******3121@**3.com",
  6.        "me": true,
  7.        "category": "drive#user"
  8.    },
  9.    "editedTime": "2020-02-19T13:13:23.635Z",
  10.    "deleted": false,
  11.    "description": "2020/02/17 11:20",
  12.    "createdTime": "2020-02-19T13:13:23.635Z",
  13.    "position": "{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':'10'}}]}",
  14.    "id": "BkytC_85-y5hoiLxCRnNCHZcDynNC_siY",
  15.    "htmlDescription": "2020/02/17 11:20",
  16.    "category": "drive#comment",
  17.    "quotedContent": {
  18.        "mimeType": "text/html",
  19.        "content": "222222"
  20.    }
  21. }

7.3 Retrieving a Comment

Introduction

Retrieves a comment using the Comments.get API.

Restrictions

1. Mandatory parameters: fileId, fields, and commentId.

2. The value of fileId cannot be a folder ID.

3. The value of fileId must match that of commentId.

4. Only the reader, writer, commenter, owner role can retrieve a comment.

5. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.readonly

Sending a Request to Retrieve a Comment

Step 1 Create a GET request to the Comments.get API.

Step 2 Set the query parameters {fileId}, {commentId}, and fields=*.

Example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/comments/{commentId}?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments/BkytC_85-y5hoiLxCRnNCHZcDynNC_siY?fields=* HTTP/1.1 Accept: application/json
  2. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk  
  3. Cache-Control: no-cache

Response example:

  1. HTTP/1.1 200 OK  
  2. {  
  3.    "creator": {
  4.        "permissionId": "299639512454136576",
  5.        "displayName": "*******3121@**3.com",
  6.        "me": true,
  7.        "category": "drive#user"
  8.    },
  9.    "editedTime": "2020-02-19T13:13:23.635Z",
  10.    "deleted": false,
  11.    "description": "2020/02/17 11:20",
  12.    "createdTime": "2020-02-19T13:13:23.635Z",
  13.    "position": "{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':'10'}}]}",
  14.    "id": "BkytC_85-y5hoiLxCRnNCHZcDynNC_siY",
  15.    "htmlDescription": "2020/02/17 11:20",
  16.    "category": "drive#comment",
  17.    "quotedContent": {
  18.        "mimeType": "text/html",
  19.        "content": "222222"
  20.    }
  21. }


7.4 Listing Comments

Introduction

Lists all comments on a file using the Comments.list API, including setting startEditedTime, which indicates the time starting from which the created comments will be listed, and pageSize, which indicates the number of comments to be displayed on each page.

Restrictions

1. Mandatory parameters: fileId and fields

2. pageSize: The value ranges from 1 to 100. If this parameter is left empty, the value 100 is used by default.

3. startEditedTime: The value must comply with the RFC3339 format requirements.

4. Currently, the form parameter has a fixed value of json. If the parameter is left empty, json is used by default.

5. Only the reader, writer, commenter, or owner role can list comments.

6. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.readonly

Note

1. Currently, the includeDeleted parameter is not used.

Sending a Request to List Comments

Step 1 Create a GET request to the Comments.list API.

Step 2 Set the query parameters {fileId} and fields=*.

Example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/comments?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments?fields=* HTTP/1.1  
  2. Accept: application/json
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk  
  4. Cache-Control: no-cache

Response example:

  1. HTTP/1.1 200 OK  
  2. {
  3.    "nextCursor": "BF5D1350B585F44D5A359F0BF8883A195",
  4.    "comments": [
  5.        {
  6.            "creator": {
  7.                "permissionId": "299639512454136576",
  8.                "displayName": "*******3121@**3.com",
  9.                "me": true,
  10.                "category": "drive#user"
  11.            },
  12.            "editedTime": "2020-02-18T06:09:33Z",
  13.            "deleted": false,
  14.            "description": "2020/02/1777 11:70",
  15.            "createdTime": "2020-02-18T06:09:33Z",
  16.            "position": "{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':'10'}}]}",
  17.            "id": "BnGCVaQyhH6CMBTwGXE1BV5hIHeWAIRyg",
  18.            "htmlDescription": "2020/02/1777 11:70",
  19.            "category": "drive#comment",
  20.            "quotedContent": {
  21.                "mimeType": "text/html",
  22.                "content": "222222"
  23.            }
  24.        },
  25.        {
  26.            "creator": {
  27.                "permissionId": "299639512454136576",
  28.                "displayName": "*******3121@**3.com",
  29.                "me": true,
  30.                "category": "drive#user"
  31.            },
  32.            "editedTime": "2020-02-18T06:21:21Z",
  33.            "deleted": false,
  34.            "description": "2020/02/1777 11:70",
  35.            "createdTime": "2020-02-18T06:21:21Z",
  36.            "position": "{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':'10'}}]}",
  37.            "id": "Bg98CUePG7_oH4b9qLUhJ04f3it1vRuz6",
  38.            "htmlDescription": "2020/02/1777 11:70",
  39.            "category": "drive#comment",
  40.            "quotedContent": {
  41.                "mimeType": "text/html",
  42.                "content": "222222"
  43.            }
  44.        },
  45.         {
  46.            "creator": {
  47.                "permissionId": "299639512454136576",
  48.                "displayName": "*******3121@**3.com",
  49.                "me": true,
  50.                "category": "drive#user"
  51.            },
  52.            "editedTime": "2020-02-18T07:18:22Z",
  53.            "deleted": false,
  54.            "description": "2020/02/178 11:70",
  55.            "createdTime": "2020-02-18T07:18:22Z",
  56.            "position": "{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':'10'}}]}",
  57.            "id": "BkvcvwRTGlCS9V1SPh0FPLZbfp02YRpck",
  58.            "htmlDescription": "2020/02/178 11:70",
  59.            "category": "drive#comment",
  60.            "quotedContent": {
  61.                "mimeType": "text/html",
  62.                "content": "222222"
  63.            }
  64.        },
  65.        {
  66.            "creator": {
  67.                "permissionId": "299639512454136576",
  68.                "displayName": "*******3121@**3.com",
  69.                "me": true,
  70.                "category": "drive#user"
  71.            },
  72.            "editedTime": "2020-02-19T13:13:24Z",
  73.            "deleted": false,
  74.            "description": "2020/02/17 11:20",
  75.            "createdTime": "2020-02-19T13:13:24Z",
  76.            "position": "{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':'10'}}]}",
  77.            "id": "BkytC_85-y5hoiLxCRnNCHZcDynNC_siY",
  78.            "htmlDescription": "2020/02/17 11:20",
  79.            "category": "drive#comment",
  80.            "quotedContent": {
  81.                "mimeType": "text/html",
  82.                "content": "222222"
  83.            }
  84.        }
  85.    ],
  86.    "category": "drive#commentList"
  87. }

7.5 Deleting a Comment

Introduction

Deletes a comment using the Comments.delete API.

Restrictions

1. Mandatory parameters: fileId and commentId

2. Only the comment creator or owner can delete a comment.

3. The value of fileId must match that of commentId.

4. Only the writer, commenter, or owner role can delete a comment.

5. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

Sending a Request to Delete a Comment

Step 1 Create a DELETE request to the Comments.delete API.

Step 2 Set the query parameters {fileId}, {commentId}, and fields=*.

Example:

  1. DELETE https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/comments/{commentId}?fields=*

Step 3 Set HTTP header fields.

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. DELETE https://drive.cloud.hicloud.com/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments/BkytC_85-y5hoiLxCRnNCHZcDynNC_siY?fields=* HTTP/1.1  
  2. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk  
  3. Cache-Control: no-cache

Response example:

  1. HTTP/1.1 204 OK


7.6 Modifying a Comment

Introduction

Modifies a comment using the Comments.update API.

Restrictions

1. Mandatory parameters: fileId, fields, and commentId.

2. Only the creator of a comment can modify the comment.

3. The value of fileId must match that of commentId.

4. The request body is mandatory and cannot be left empty. description cannot be left empty but can be set to " ". The value can consist of 1024 bytes. To update a comment, the request only needs to contain the description and position parameters. If the request contains other parameters, no error will be reported and these parameters will not be processed.

5. Only the writer, commenter, or owner role can update a comment.

6. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

Sending a Request to Modify a Comment

Step 1 Create a PATCH request to the Comments.update API.

Step 2 Set the query parameters {fileId}, {commentId}, and fields=*.

Example:

  1. PATCH https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/comments/{commentId}?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. PATCH https://drive.cloud.hicloud.com/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments/BkytC_85-y5hoiLxCRnNCHZcDynNC_siY?fields=* HTTP/1.1
  2. Accept: application/json  
  3. Content-Type: application/x-www-form-urlencoded  
  4. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk  
  5. Cache-Control: no-cache  
  6. {  
  7.    "description":"2020/02/18 11:20"
  8. }

Response example:

  1. HTTP/1.1 200 OK  
  2. {  
  3.    "creator": {
  4.        "permissionId": "299639512454136576",
  5.        "displayName": "*******3121@**3.com",
  6.        "me": true,
  7.        "category": "drive#user"
  8.    },
  9.    "editedTime": "2020-02-19T13:13:23.635Z",
  10.    "deleted": false,
  11.    "description": "2020/02/18 11:20",
  12.    "createdTime": "2020-02-19T13:13:23.635Z",
  13.    "position": "{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':'10'}}]}",
  14.    "id": "BkytC_85-y5hoiLxCRnNCHZcDynNC_siY",
  15.    "htmlDescription": "2020/02/17 11:20",
  16.    "category": "drive#comment",
  17.    "quotedContent": {
  18.        "mimeType": "text/html",
  19.        "content": "222222"
  20.    }
  21. }


8 Replying to Comments

8.1 Use Case

HUAWEI Drive Kit allows your app to provide the reply function for users, including adding, viewing, updating, and deleting replies to comments on files in the cloud.

8.2 Creating a Reply

Introduction

Creates a reply to a comment using the Replies.create API.

Restrictions

1. Mandatory parameters: fileId, commentId and fields

2. Currently, the form parameter has a fixed value of json. If the parameter is left empty, json is used by default.

3. Only the writer, commenter, or owner role can create a reply.

4. The scope value must be one of the following:

https://www.huawei.com/auth/drive.file

https://www.huawei.com/auth/drive

5. A reply cannot be created for a folder.

6. A maximum of 20 replies can be created for a comment.

7. The request body is optional, in which the value of operate can be set to reopen or resolve.

Sending a Request to Reply to a Comment

Step 1 Create a POST request to the Replies.create API.

Step 2 Set the query parameters {fileId}, {commentId}, and fields=*.

Example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/comments/{commentId}/replies?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. POST https://drive.cloud.hicloud.com/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments/BkytC_85-y5hoiLxCRnNCHZcDynNC_siY/replies?fields=* HTTP/1.1  
  2. Accept: application/json  
  3. Content-Type: application/x-www-form-urlencoded  
  4. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk  
  5. Cache-Control: no-cache  
  6. {  
  7.    "description":"HuaweiTest001",
  8.    "operate":"reopen"
  9. }

Response example:

  1. HTTP/1.1 200 OK  
  2. {
  3.    "creator": {
  4.        "permissionId": "299639512454136576",
  5.        "displayName": "*******3121@**3.com",
  6.        "me": true,
  7.        "category": "drive#user"
  8.    },
  9.    "editedTime": "2020-02-19T13:49:32.862Z",
  10.    "operate": "reopen",
  11.    "deleted": false,
  12.    "createdTime": "2020-02-19T13:49:32.862Z",
  13.    "description": "HuaweiTest001",
  14.    "id": "BpMy9fyvWDfDM2rRKzfpNbqDkNfOnVg7w",
  15.    "category": "drive#reply",
  16.    "htmlDescription": "HuaweiTest001"
  17. }

8.3 Retrieving a Reply

Introduction

Retrieves a reply to a comment using the Replies.get API.

Restrictions

1. Mandatory parameters: fileId, commentId, replyId, and fields

2. Only the reader, writer, commenter, or owner role can retrieve a reply.

3. The scope value must be one of the following:

https://www.huawei.com/auth/drive.file

https://www.huawei.com/auth/drive

https://www.huawei.com/auth/drive.readonly

4. Currently, the form parameter has a fixed value of json. If the parameter is left empty, json is used by default.

Sending a Request to Retrieve a Reply

Step 1 Create a GET request to the Replies.get API.

Step 2 Set the query parameters {fileId}, {commentId}, {replyId}, and fields=*.

Example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/comments/{commentId}/replies/{replyId}?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments/BkytC_85-y5hoiLxCRnNCHZcDynNC_siY/replies/BpMy9fyvWDfDM2rRKzfpNbqDkNfOnVg7w?fields=* HTTP/1.1  
  2. Accept: application/json  
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk  
  4. Cache-Control: no-cache

Response example:

  1. HTTP/1.1 200 OK  
  2. {
  3.    "creator": {
  4.        "permissionId": "299639512454136576",
  5.        "displayName": "*******3121@**3.com",
  6.        "me": true,
  7.        "category": "drive#user"
  8.    },
  9.    "editedTime": "2020-02-19T13:49:32.862Z",
  10.    "operate": "reopen",
  11.    "deleted": false,
  12.    "createdTime": "2020-02-19T13:49:32.862Z",
  13.    "description": "HuaweiTest001",
  14.    "id": "BpMy9fyvWDfDM2rRKzfpNbqDkNfOnVg7w",
  15.    "category": "drive#reply",
  16.    "htmlDescription": "HuaweiTest001"
  17. }

8.4 Listing Replies to a Comment

Introduction

Lists all replies to a comment using the Replies.list API, including setting pageSize, which indicates the number of replies to be displayed on each page.

Restrictions

1. Mandatory parameters: fileId, commentId and fields

2. pageSize: The value ranges from 1 to 100. If this parameter is left empty, the value 20 is used by default.

3. Currently, the form parameter has a fixed value of json. If the parameter is left empty, json is used by default.

4. Only the reader, writer, commenter, or owner role can list replies.

5. The scope value must be one of the following:

    https://www.huawei.com/auth/drive.file

    https://www.huawei.com/auth/drive

    https://www.huawei.com/auth/drive.readonly

Note

1. Currently, the includeDeleted parameter is not used.

Sending a Request to List Replies

Step 1 Create a GET request to the Replies.list API.

Step 2 Set the query parameters {fileId}, {commentId}, and fields=*.

Example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/comments/{commentId}/replies?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. GET https://drive.cloud.hicloud.com/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments/BkytC_85-y5hoiLxCRnNCHZcDynNC_siY/replies?fields=* HTTP/1.1  
  2. Accept: application/json  
  3. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk  
  4. Cache-Control: no-cache

Response example:

  1. HTTP/1.1 200 OK  
  2. {
  3.    "nextCursor": "BCCDAB44ACDFA4D6EA0E435F3A7560EF0",
  4.    "replies": [
  5.        {
  6.            "creator": {
  7.                "permissionId": "299639512454136576",
  8.                "displayName": "*******3121@**3.com",
  9.                "me": true,
  10.                "category": "drive#user"
  11.            },
  12.            "editedTime": "2020-02-19T13:56:31Z",
  13.            "operate": "reopen",
  14.            "deleted": false,
  15.            "createdTime": "2020-02-19T13:56:31Z",
  16.            "description": "HuaweiTest003",
  17.            "id": "Bv_vRsfoUCBJmbCvafSFNQrvTWT12lAsS",
  18.            "category": "drive#reply",
  19.            "htmlDescription": "HuaweiTest003"
  20.        },
  21.        {
  22.            "creator": {
  23.                "permissionId": "299639512454136576",
  24.                "displayName": "*******3121@**3.com",
  25.                "me": true,
  26.                "category": "drive#user"
  27.            },
  28.            "editedTime": "2020-02-19T13:56:26Z",
  29.            "operate": "reopen",
  30.            "deleted": false,
  31.            "createdTime": "2020-02-19T13:56:26Z",
  32.            "description": "HuaweiTest002",
  33.            "id": "BvGxpclcpKkC2hMquGAZI4bhE4f7bqSlA",
  34.            "category": "drive#reply",
  35.            "htmlDescription": "HuaweiTest002"
  36.        },
  37.        {
  38.            "creator": {
  39.                "permissionId": "299639512454136576",
  40.                "displayName": "*******3121@**3.com",
  41.                "me": true,
  42.                "category": "drive#user"
  43.            },
  44.            "editedTime": "2020-02-19T13:49:33Z",
  45.            "operate": "reopen",
  46.            "deleted": false,
  47.            "createdTime": "2020-02-19T13:49:33Z",
  48.            "description": "HuaweiTest001",
  49.            "id": "BpMy9fyvWDfDM2rRKzfpNbqDkNfOnVg7w",
  50.            "category": "drive#reply",
  51.            "htmlDescription": "HuaweiTest001"
  52.        }
  53.    ],
  54.    "category": "drive#replyList"
  55. }

8.5 Deleting a Reply

Introduction

Deletes a reply to a comment using the Replies.delete API.

Restrictions

1. Mandatory parameters: fileId, commentId, and replyId

2. Only the writer, commenter, or owner role can delete a reply.

3. The scope value must be one of the following:

https://www.huawei.com/auth/drive.file

https://www.huawei.com/auth/drive

4. Only the creator of a reply or file can delete the reply.

Sending a Request to Delete a Reply

Step 1 Create a DELETE request to the Replies.delete API.

Step 2 Set the query parameters {fileId}, {commentId}, {replyId}, and fields=*.

Example:

  1. DELETE https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/comments/{commentId}/replies/{replyId}?fields=*

Step 3 Set HTTP header fields.

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. DELETE https://drive.cloud.hicloud.com/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments/BkytC_85-y5hoiLxCRnNCHZcDynNC_siY/replies/BpMy9fyvWDfDM2rRKzfpNbqDkNfOnVg7w?fields=* HTTP/1.1  
  2. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk  
  3. Cache-Control: no-cache

Response example:

  1. HTTP/1.1 204 OK


8.6 Modifying a Reply

Introduction

Modifies a reply to a comment using the Replies.update API.

Restrictions

1. Mandatory parameters: fileId, commentId, replyId, and fields

2. The request body is mandatory and the description parameter in it is also mandatory.

3. Only the writer, commenter, or owner role can modify a reply.

4. The scope value must be one of the following:

https://www.huawei.com/auth/drive.file

https://www.huawei.com/auth/drive

5. A reply cannot be updated for a folder.

6. Only the creator of a reply can update the reply.

7. Currently, the form parameter has a fixed value of json. If the parameter is left empty, json is used by default.

Sending a Request to Modify a Reply

Step 1 Create a PATCH request to the Replies.update API.

Step 2 Set the query parameters {fileId}, {commentId}, {replyId}, and fields=*.

Example:

  1. PATCH https://drive.cloud.hicloud.com/drive/v1/files/{fileId}/comments/{commentId}/replies/{replyId}?fields=*

Step 3 Set HTTP header fields.

Accept: media type that is acceptable for the response

Content-Type: media type of the request

Cache-Control: directives to be obeyed by the caching mechanism

Authorization: authorization code obtained from the HUAWEI Account server

Step 4 Send the request.

Request example:

  1. PATCH https://drive.cloud.hicloud.com/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments/BkytC_85-y5hoiLxCRnNCHZcDynNC_siY/replies/BpMy9fyvWDfDM2rRKzfpNbqDkNfOnVg7w?fields=* HTTP/1.1  
  2. Accept: application/json  
  3. Content-Type: application/x-www-form-urlencoded  
  4. Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk  
  5. Cache-Control: no-cache  
  6. {  
  7.    "description":"HuaweiTest011",
  8.    "operate":"reopen"
  9. }

Response example:

  1. HTTP/1.1 200 OK  
  2. {
  3.    "creator": {
  4.        "permissionId": "299639512454136576",
  5.        "displayName": "*******3121@**3.com",
  6.        "me": true,
  7.        "category": "drive#user"
  8.    },
  9.    "editedTime": "2020-02-19T13:49:32.862Z",
  10.    "operate": "reopen",
  11.    "deleted": false,
  12.    "createdTime": "2020-02-19T13:49:32.862Z",
  13.    "description": "HuaweiTest011",
  14.    "id": "BpMy9fyvWDfDM2rRKzfpNbqDkNfOnVg7w",
  15.    "category": "drive#reply",
  16.    "htmlDescription": "HuaweiTest001"
  17. }