By calling the Changes.list API, your app can list file changes after receiving a notification.
Protocol | HTTP GET |
|---|---|
Direction | Developer server -> HUAWEI Drive server |
URL | https://driveapis.cloud.huawei.com.cn/drive/v1/changes |
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
includeDeleted | Optional | string | Indicates whether to include file deletion records in the file change list. The default value is true. To be compatible with the on-device SDK, both isIncludeDeleted and includeDeleted are supported. If both parameters are passed, the value of includeDeleted takes precedence. |
pageSize | Optional | integer | Maximum number of results to return per page. The default value is 100. The value ranges from 1 to 100. Note: It is possible that partial or empty result pages are returned before the end of the result list has been reached. |
cursor | Mandatory | string | Cursor for the current page, which is obtained from nextCursor in the previous response. |
containers | Optional | string | Query scope. The value can be drive, applicationData, or a combination of the two (separated by a comma). The default value is drive. |
fields | Optional | string | Fields in the request, which are in the partial response format. For details, please refer to Overview. |
form | Optional | string | Media format. |
prettyPrint | Optional | boolean | Indicates whether to return a response in a human-readable format. |
quotaId | Optional | string | User identifier, which can contain a maximum of 40 characters. This parameter is used to restrict the maximum number of API calls for a single user. |
callback | Optional | string | Callback function used in JSONP requests. |
Request Header
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
x-hw-trace-id | Optional | string | ID used for service tracing. |
x-hw-app-id | Optional | string | App ID. |
version | Optional | string | SDK version number. |
x-hw-terminal | Optional | string | Device model. |
x-hw-os | Optional | string | Device operating system. |
unionID | Optional | string | User's UnionID. |
User-Agent | Optional | string | App version number or app ID. |
x-hw-deviceUUID | Optional | string | UUID of the device. |
x-hw-deviceUDID | Optional | string | UDID of the device. |
x-hw-appPackageName | Optional | string | App package name. |
x-hw-network | Optional | string | Network type. The options include WiFi, 2G, 3G, 4G, 5G, and wire. |
Request Body
None.
GET https://driveapis.cloud.huawei.com.cn/drive/v1/changes?cursor=238247332125117440&fields=* HTTP/1.1 Content-Type: application/json Authorization: Bearer CV3PnPLZXyr9K2GV7RYZkF962JZvoEkMQhTho3QHQAPQUyma/lEyZskP/IMWrc7FvaeHivO7y0lyibI/fQvulBnTgtXArSVPsjaLKvYNkDsJSaIR2/sx+K40bYDWWpKFvJNKg2U47jRwz2mfiF3ortNk Cache-Control: no-cache
When the status code is 200:
Parameter | Type | Description |
|---|---|---|
category | string | Resource type. The value is always drive#changeList. |
nextCursor | string | Next cursor. |
newStartCursor | string | New start cursor for the change. |
changes[] | list | List of changes. |
changes.category | string | Resource type. The value is always drive#change. |
changes.type | string | Resource type for the change. |
changes.changeType | string | Change type. |
changes.time | string | Time when the change is made. |
changes.deleted | boolean | Indicates whether the resource has been deleted. |
changes.fileId | string | File ID. |
changes.file.category | string | Resource type. The value is always drive#file. |
changes.file.id | string | File ID. |
changes.file.fileName | string | File name. |
changes.file.mimeType | string | MIME type of the file. |
changes.file.description | string | Short description of the file. |
changes.file.favorite | boolean | Indicates whether the file has been favorited. |
changes.file.recycled | boolean | Indicates whether the file has been moved to the recycle bin. |
changes.file.directlyRecycled | boolean | Indicates whether the file has been explicitly moved to the recycle bin. |
changes.file.recyclingUser.category | string | User type. The value is always drive#user. |
changes.file.recyclingUser.displayName | string | Display name of the user. |
changes.file.recyclingUser.profilePhotoLink | string | Link to the user's profile picture, which is not returned by default. |
changes.file.recyclingUser.me | boolean | Indicates whether the user is the requesting user. |
changes.file.recyclingUser.permissionId | string | Permission ID. |
changes.file.recyclingUser.userAccount | string | Account of the user, which is not returned by default. |
changes.file.recycledTime | string | Time when the file is moved to the recycle bin. |
changes.file.parentFolder[] | string | Parent folder. |
changes.file.properties | string | Custom file properties that are universally visible. |
changes.file.appSettings | string | Customized app attribute. |
changes.file.containers[] | string | Spaces that contain the file. The options include drive and applicationData. |
changes.file.version | integer | Version number of the file. |
changes.file.contentDownloadLink | string | Link for downloading the file in a browser. |
changes.file.iconDownloadLink | string | Link to the file's icon. |
changes.file.existThumbnail | boolean | Indicates whether the file has a thumbnail. |
changes.file.thumbnailDownloadLink | string | Link to the file's large thumbnail. |
changes.file.smallThumbnailDownloadLink | string | Link to the file's small thumbnail. |
changes.file.thumbnailVersion | integer | Thumbnail version number. |
changes.file.onLineViewLink | string | Link to view the file online. |
changes.file.createdTime | string | Time when the file is created. |
changes.file.editedTime | string | Last time when the file is modified. |
changes.file.editedByMeTime | string | Last time when the file is modified by the user. |
changes.file.editedByMe | boolean | Indicates whether the file is modified by the user. |
changes.file.sharedWithMeTime | string | Time when the file is shared with the user. |
changes.file.sharer.category | string | User type. The value is always drive#user. |
changes.file.sharer.displayName | string | Display name of the user. |
changes.file.sharer.profilePhotoLink | string | Link to the user's profile picture, which is not returned by default. |
changes.file.sharer.me | boolean | Indicates whether the user is the requesting user. |
changes.file.sharer.permissionId | string | Permission ID. |
changes.file.sharer.userAccount | string | Account of the user, which is not returned by default. |
changes.file.owners.category | string | User type. The value is always drive#user. |
changes.file.owners.displayName | string | Display name of the user. |
changes.file.owners.profilePhotoLink | string | Link to the user's profile picture, which is not returned by default. |
changes.file.owners.me | boolean | Indicates whether the user is the requesting user. |
changes.file.owners.permissionId | string | Permission ID. |
changes.file.owners.userAccount | string | Account of the user, which is not returned by default. |
changes.file.lastEditor.category | string | User type. The value is always drive#user. |
changes.file.lastEditor.displayName | string | Display name of the user. |
changes.file.lastEditor.profilePhotoLink | string | Link to the user's profile picture, which is not returned by default. |
changes.file.lastEditor.me | boolean | Indicates whether the user is the requesting user. |
changes.file.lastEditor.permissionId | string | Permission ID. |
changes.file.lastEditor.userAccount | string | Account of the user, which is not returned by default. |
changes.file.hasShared | boolean | Indicates whether the file is shared. |
changes.file.ownedByMe | boolean | Indicates whether the user owns the file. |
changes.file.capabilities.addChildNodePermission | boolean | Indicates whether the current user has permission to create subfolders or files to a folder. |
changes.file.capabilities.writerHasChangeCopyPermission | boolean | Indicates whether the current user (assuming the writer role) has permission to change or copy the file. |
changes.file.capabilities.commentPermission | boolean | Indicates whether the current user has permission to comment on the file. |
changes.file.capabilities.copyPermission | boolean | Indicates whether the current user has permission to copy the file. |
changes.file.capabilities.deletePermission | boolean | Indicates whether the current user has permission to delete the file. |
changes.file.capabilities.downloadPermission | boolean | Indicates whether the current user has permission to download the file. |
changes.file.capabilities.editPermission | boolean | Indicates whether the current user has permission to edit the file. |
changes.file.capabilities.listChildNodePermission | boolean | Indicates whether the current user has permission to list subfolders or files in a folder. |
changes.file.capabilities.editContentPermission | boolean | Indicates whether the current user has permission to modify the content of the file. |
changes.file.capabilities.readHistoryVersionPermission | boolean | Indicates whether the current user has permission to read the historical versions of the file. |
changes.file.capabilities.removeChildNodePermission | boolean | Indicates whether the current user has permission to remove subfolders from a folder. |
changes.file.capabilities.renameFilePermission | boolean | Indicates whether the current user has permission to rename the file. |
changes.file.capabilities.shareFilePermission | boolean | Indicates whether the current user has permission to share the file. |
changes.file.capabilities.recyclePermission | boolean | Indicates whether the current user has permission to move the file to the recycle bin. |
changes.file.capabilities.unrecyclePermission | boolean | Indicates whether the current user has permission to restore the file from the recycle bin. |
changes.file.viewersHasCopyContentPermission | boolean | Indicates whether the current user has permission to copy the content of the file. |
changes.file.writerHasCopyPermission | boolean | Indicates whether the current user (assuming the writer role) has permission to copy the file. |
changes.file.writersHasSharePermission | boolean | Indicates whether the current user (assuming the writer role) has permission to share the file. |
changes.file.permissions[] | list | List of permissions for the file. |
changes.file.permissions.category | string | Permission category. The value is always drive#permission. |
changes.file.permissions.id | string | Permission ID. |
changes.file.permissions.type | string | Type of the grantee, which can be user or anyone. |
changes.file.permissions.role | string | Role granted by the permission. The options include owner, writer, commenter, and reader. |
changes.file.permissions.userAccount | string | Account of the user. |
changes.file.permissions.displayName | string | Display name of the permission. |
changes.file.permissions.expirationTime | string | Time when the permission expires. |
changes.file.permissions.deleted | boolean | Indicates whether the resource file permission is deleted. |
changes.file.permissions.canDiscoverFile | boolean | Indicates whether the permission allows the file to be searched. It is applicable only to permissions of the anyone type. |
changes.file.permissionIds | list | List of permission IDs for users with access to the file. |
changes.file.originalFilename | string | Original file name. |
changes.file.fullFileSuffix | string | Full file name suffix extracted from the name field. It is the substring that comes immediately after the dot character in the file name. |
changes.file.fileSuffix | string | Last component of fullFileSuffix. |
changes.file.size | integer | File size. |
changes.file.occupiedSpace | integer | Actual storage used by the file. |
changes.file.pictureMetadata.width | integer | Picture width. |
changes.file.pictureMetadata.height | integer | Picture height. |
changes.file.pictureMetadata.location.latitude | number | Latitude stored in the picture. |
changes.file.pictureMetadata.location.longitude | number | Longitude stored in the picture. |
changes.file.pictureMetadata.location.altitude | number | Altitude stored in the picture. |
changes.file.pictureMetadata.exifTime | string | Date and time when the picture is created (EXIF DateTime). |
changes.file.pictureMetadata.cameraMaker | string | Maker of the camera that is used to create the picture. |
changes.file.pictureMetadata.cameraModel | string | Model of the camera that is used to create the picture. |
changes.file.pictureMetadata.exposureTime | number | Length of the exposure, in seconds. |
changes.file.pictureMetadata.aperture | number | Aperture (f-number) used to create the picture. |
changes.file.pictureMetadata.flashUsed | boolean | Indicates whether a flash is used to create the picture. |
changes.file.pictureMetadata.focalLength | number | Focal length used to create the picture, in millimeters. |
changes.file.pictureMetadata.isoSpeed | integer | ISO speed used to create the picture. |
changes.file.pictureMetadata.meteringMode | string | Metering mode used to create the picture. |
changes.file.pictureMetadata.sensor | string | Type of sensor used to create the picture. |
changes.file.pictureMetadata.exposureMode | string | Exposure mode used to create the picture. |
changes.file.pictureMetadata.colorSpace | string | Color space of the picture. |
changes.file.pictureMetadata.whiteBalance | string | White balance mode used to create the picture. |
changes.file.pictureMetadata.exposureBias | number | Exposure bias of the picture (APEX value). |
changes.file.pictureMetadata.maxApertureValue | number | Maximum aperture used to create the picture (APEX value). |
changes.file.pictureMetadata.lens | string | Lens used to create the picture. |
changes.file.videoMetadata.width | integer | Width of the video. |
changes.file.videoMetadata.height | integer | Height of the video. |
changes.file.videoMetadata.durationTime | integer | Duration of the video, in milliseconds. |
changes.file.sha256 | string | SHA-256 value for the file. |
changes.file.lastHistoryVersionId | string | ID of the latest version. |
changes.file.contentVersion | string | Content version number. |
{
"changes":[
{
"deleted":false,
"file":{
"fileName":"W27",
"editedByMe":true,
"description":"folder",
"owners":[
{
"permissionId":"233228122990838144",
"displayName":"*******3121@**3.com",
"me":true,
"category":"drive#user"
}
],
"hasShared":false,
"mimeType":"application/vnd.huawei-apps.folder",
"permissionIds":[
"233228122990838144"
],
"directlyRecycled":false,
"recycled":false,
"permissions":[
{
"role":"owner",
"deleted":false,
"displayName":"*******3121@**3.com",
"id":"233228122990838144",
"category":"drive#permission",
"type":"user"
}
],
"editedByMeTime":"2020-06-15T09:43:59Z",
"createdTime":"2020-06-15T09:43:59Z",
"id":"Bruy7elw_fApIT4Fyj2FIVa3QLMeiv32K",
"capabilities":{
"downloadPermission":true,
"renameFilePermission":true,
"commentPermission":true,
"deletePermission":true,
"readHistoryVersionPermission":true,
"recyclePermission":true,
"addChildNodePermission":true,
"unrecyclePermission":true,
"writerHasChangeCopyPermission":false,
"copyPermission":false,
"editContentPermission":true,
"removeChildNodePermission":true,
"editPermission":true,
"listChildNodePermission":true,
"shareFilePermission":true
},
"ownedByMe":true,
"version":1,
"viewedByMe":false,
"writersHasSharePermission":false,
"iconDownloadLink":"https://event-dre.dbankcdn.com/filemanagerpic/20191114091142H5kH.png",
"editedTime":"2020-06-15T09:43:59Z",
"writerHasCopyPermission":false,
"lastEditor":{
"permissionId":"233228122990838144",
"displayName":"*******3121@**3.com",
"me":true,
"category":"drive#user"
},
"existThumbnail":false,
"containers":[
"drive"
],
"category":"drive#file",
"favorite":false
},
"changeType":"File",
"time":"2020-06-15T09:43:59Z",
"category":"drive#change",
"type":"File",
"fileId":"Bruy7elw_fApIT4Fyj2FIVa3QLMeiv32K"
}
],
"newStartCursor":"2312",
"category":"drive#changeList"
} Status Code | Result Code | Response Code | Description |
|---|---|---|---|
200 | NA | - | Success. |
400 | 21004001 | LACK_OF_PARAM | Input parameter is missing. Check the parameter list. |
400 | 21004002 | PARAM_INVALID | Parameter verification failed. Check the parameter list. |
400 | 21004003 | PARAM_VALUE_NOT_SUPPORT | Invalid parameter. Check the parameter list. |
403 | 21004035 | INSUFFICIENT_SCOPE | Scope verification failed. |
500 | 21055002 | OUTER_SERVICE_UNAVAILABLE | External service is unavailable. |
403 | 21074033 | AGREEMENT_NOT_SIGNED | The HUAWEI Drive user agreement is not signed. Try again after the agreement is signed. |
For details about other result codes, please refer to Status Codes.
public static void main(String[] args) throws IOException {
// Set the request URL, cursor for the current page, and access token.
String url = "https://driveapis.cloud.huawei.com.cn/drive/v1/changes";
String cursor = "299830100109593600";// Obtain the cursor for the current page through the ChangesGetStartCursor API.
String access_token = "CV5OXuNUJzKnbGq9i7Oww6tO8huw4yu9MeJrxPmcfuOOmNkjdZjXzXT6dK6Z2i9yps64Vtf02T6+JXQbMMVrhQ/F/PXqFvlWrG8tJz8OwHlWB+8EuHlygw==";
// List changes.
JSONObject changesInfo = changesList(url, access_token, cursor);
System.out.println(changesInfo.toJSONString());
}
private static JSONObject changesList(String url, String access_token, String cursor) throws IOException {
StringBuilder stringBuilder = new StringBuilder("");
stringBuilder.append("?").append("fields=*").append("&").append("cursor").append("=").append(cursor);
HttpGet httpGet = new HttpGet(url + stringBuilder);
httpGet.setHeader("Authorization","Bearer " + access_token);
CloseableHttpResponse response = HttpClientUtil.getClient().execute(httpGet);
try {
HttpEntity responseEntity = response.getEntity();
String ret = responseEntity != null ? EntityUtils.toString(responseEntity) : null;
JSONObject jsonObject = (JSONObject) JSON.parse(ret);
EntityUtils.consume(responseEntity);
return jsonObject;
}finally {
response.close();
}
}