目录

Commenting on Files

Use Cases

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

Creating a Comment

Introduction

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

Restrictions

Sending a Request to Create a Comment on a File

  1. Create a POST request to the Comments.create API.
  2. Set the query parameters fileId and fields.

    Example:

    POST https://driveapis.cloud.huawei.com.cn/drive/v1/files/{fileId}/comments?fields=*

  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.

  4. Send the request.

    Request example:
    POST https://driveapis.cloud.huawei.com.cn/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments?fields=* HTTP/1.1 
    Accept: application/json 
    Content-Type: application/json 
    Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk 
    Cache-Control: no-cache 
    
    { 
        "description":"2020/02/17 11:20",
        "quotedContent":{"mimeType":"text/html","content":"222222"},
        "position":"{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':10}}]}"
    }

    Response example:

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

Retrieving a Comment

Introduction

Obtains a comment using the Comments.get API.

Restrictions

Sending a Request to Obtain a Comment

  1. Create a GET request to the Comments.get API.
  2. Set the query parameters fileId, commentId, and fields.

    Example:

    GET https://driveapis.cloud.huawei.com.cn/drive/v1/files/{fileId}/comments/{commentId}?fields=*

  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.

  4. Send the request.

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

    Response example:

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

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

Note

Currently, the includeDeleted parameter is not used.

Sending a Request to List Comments

  1. Create a GET request to the Comments.list API.
  2. Set the query parameters fileId and fields.

    Example:

    GET https://driveapis.cloud.huawei.com.cn/drive/v1/files/{fileId}/comments?fields=*

  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.

  4. Send the request.

    Request example:
    GET https://driveapis.cloud.huawei.com.cn/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments?fields=* HTTP/1.1 
    Accept: application/json
    Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk 
    Cache-Control: no-cache 

    Response example:

    HTTP/1.1 200 OK 
    {
        "nextCursor": "BF5D1350B585F44D5A359F0BF8883A195",
        "comments": [
            {
                "creator": {
                    "permissionId": "299639512454136576",
                    "displayName": "*******3121@**3.com",
                    "me": true,
                    "category": "drive#user"
                },
                "editedTime": "2020-02-18T06:09:33Z",
                "deleted": false,
                "description": "2020/02/1777 11:70",
                "createdTime": "2020-02-18T06:09:33Z",
                "position": "{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':10}}]}",
                "id": "BnGCVaQyhH6CMBTwGXE1BV5hIHeWAIRyg",
                "htmlDescription": "2020/02/1777 11:70",
                "category": "drive#comment",
                "quotedContent": {
                    "mimeType": "text/html",
                    "content": "222222"
                }
            },
            {
                "creator": {
                    "permissionId": "299639512454136576",
                    "displayName": "*******3121@**3.com",
                    "me": true,
                    "category": "drive#user"
                },
                "editedTime": "2020-02-18T06:21:21Z",
                "deleted": false,
                "description": "2020/02/1777 11:70",
                "createdTime": "2020-02-18T06:21:21Z",
                "position": "{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':10}}]}",
                "id": "Bg98CUePG7_oH4b9qLUhJ04f3it1vRuz6",
                "htmlDescription": "2020/02/1777 11:70",
                "category": "drive#comment",
                "quotedContent": {
                    "mimeType": "text/html",
                    "content": "222222"
                }
            },
             {
                "creator": {
                    "permissionId": "299639512454136576",
                    "displayName": "*******3121@**3.com",
                    "me": true,
                    "category": "drive#user"
                },
                "editedTime": "2020-02-18T07:18:22Z",
                "deleted": false,
                "description": "2020/02/178 11:70",
                "createdTime": "2020-02-18T07:18:22Z",
                "position": "{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':10}}]}",
                "id": "BkvcvwRTGlCS9V1SPh0FPLZbfp02YRpck",
                "htmlDescription": "2020/02/178 11:70",
                "category": "drive#comment",
                "quotedContent": {
                    "mimeType": "text/html",
                    "content": "222222"
                }
            },
            {
                "creator": {
                    "permissionId": "299639512454136576",
                    "displayName": "*******3121@**3.com",
                    "me": true,
                    "category": "drive#user"
                },
                "editedTime": "2020-02-19T13:13:24Z",
                "deleted": false,
                "description": "2020/02/17 11:20",
                "createdTime": "2020-02-19T13:13:24Z",
                "position": "{'revision':'1-0','region':[{'line':{'ln':1,'len':2,'flen':10}}]}",
                "id": "BkytC_85-y5hoiLxCRnNCHZcDynNC_siY",
                "htmlDescription": "2020/02/17 11:20",
                "category": "drive#comment",
                "quotedContent": {
                    "mimeType": "text/html",
                    "content": "222222"
                }
            }
        ],
        "category": "drive#commentList"
    }

Deleting a Comment

Introduction

Deletes a comment using the Comments.delete API.

Restrictions

Sending a Request to Delete a Comment

  1. Create a DELETE request to the Comments.delete API.
  2. Set the query parameters fileId and commentId.

    Example:

    DELETE https://driveapis.cloud.huawei.com.cn/drive/v1/files/{fileId}/comments/{commentId}

  3. Set HTTP header fields.

    • Cache-Control: directives to be obeyed by the caching mechanism.
    • Authorization: authorization code obtained from the HUAWEI Account server.

  4. Send the request.

    Request example:
    DELETE https://driveapis.cloud.huawei.com.cn/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments/BkytC_85-y5hoiLxCRnNCHZcDynNC_siY HTTP/1.1 
    Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk 
    Cache-Control: no-cache 

    Response example:

    HTTP/1.1 204 OK

Modifying a Comment

Introduction

Updates a comment using the Comments.update API.

Restrictions

Sending a Request to Update a Comment

  1. Create a PATCH request to the Comments.update API.
  2. Set the query parameters fileId, commentId, and fields.

    Example:

    PATCH https://driveapis.cloud.huawei.com.cn/drive/v1/files/{fileId}/comments/{commentId}?fields=*

  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.

  4. Send the request.

    Request example:
    PATCH https://driveapis.cloud.huawei.com.cn/drive/v1/files/AAAB9Wn0DTQCIqPbW9avGjAQo9dbxg04A/comments/BkytC_85-y5hoiLxCRnNCHZcDynNC_siY?fields=* HTTP/1.1
    Accept: application/json 
    Content-Type: application/json 
    Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk 
    Cache-Control: no-cache 
    
    { 
        "description":"2020/02/18 11:20"
    }

    Response example:

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