目录

Changes:list

功能介绍

获取变更列表。

场景描述

应用收到第三方下发的通知后,调用Changes.list接口,获取用户文件变化。

使用约束

接口原型

承载协议

HTTP GET

接口方向

开发者服务器->华为云空间服务器

接口URL

https://driveapis.cloud.huawei.com.cn/drive/v1/changes

数据格式

请求消息:Content-Type: application/json

响应消息:Content-Type: application/json

路径参数

无

查询参数

参数

是否必选

参数类型

描述

includeDeleted

否

string

是否包含删除,默认值为true。为兼容端侧SDK,该字段的参数也支持isIncludeDeleted的传递方式,如果传入值两者都有的情况下,以includeDeleted传递的值为准。

pageSize

否

integer

每页返回的个数,默认是100,可接受值1-100。注意在到达最后的列表之前,实际有可能返回部分或者空结果。

cursor

是

string

当前页游标,由前一个响应的nextCursor获取。

containers

否

string

查询范围,可选值drive和applicationData,或两者的组合,以逗号连接。默认是drive。

fields

否

string

采用[Partial-response格式],具体使用见公共说明。

form

否

string

媒体格式。

prettyPrint

否

boolean

是否以美观格式输出。

quotaId

否

string

用户标识,小于40个字符。用于限制单个用户的API访问数量。

callback

否

string

JSONP的callback函数。

请求参数

Request Header

参数

是否必选

参数类型

描述

Authorization

是

string

用户鉴权信息 AccessToken(即AT)

x-hw-trace-id

否

string

业务跟踪id。

x-hw-app-id

否

string

应用的appid。

version

否

string

SDK版本。

x-hw-terminal

否

string

终端型号。

x-hw-os

否

string

终端操作系统类型。

unionID

否

string

用户的unionID。

User-Agent

否

string

应用版本号/appid。

x-hw-deviceUUID

否

string

设备UUID。

x-hw-deviceUDID

否

string

设备UDID。

x-hw-appPackageName

否

string

应用包名。

x-hw-network

否

string

网络类型,[WiFi, 2G, 3G, 4G, 5G, wire]。

Request Body

无

请求示例

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

响应参数

状态码为200时:

参数

参数类型

描述

category

string

类型,固定为drive#changeList。

nextCursor

string

下一cursor。

newStartCursor

string

新开始的cursor。

changes[]

list

变更列表。

changes.category

string

类型,固定为drive# change。

changes.type

string

变更的资源类型。

changes.changeType

string

变更类型

changes.time

string

变更时间。

changes.deleted

boolean

资源是否被删除。

changes.fileId

string

文件ID。

changes.file.category

string

类型,固定为drive#file。

changes.file.id

string

文件id。

changes.file.fileName

string

文件名。

changes.file.mimeType

string

文件类型。

changes.file.description

string

文件描述。

changes.file.favorite

boolean

文件是否被收藏。

changes.file.recycled

boolean

文件是否被放入回收站。

changes.file.directlyRecycled

boolean

文件是否被直接被放入回收站。

changes.file.recyclingUser.category

string

类型,固定为drive#user。

changes.file.recyclingUser.displayName

string

用户显示名。

changes.file.recyclingUser.profilePhotoLink

string

用户头像链接(默认不返回)。

changes.file.recyclingUser.me

boolean

是否是我。

changes.file.recyclingUser.permissionId

string

权限id。

changes.file.recyclingUser.userAccount

string

帐号名称(默认不返回)。

changes.file.recycledTime

string

放入回收站的时间。

changes.file.parentFolder[]

string

父目录。

changes.file.properties

string

文件公共自定义属性。

changes.file.appSettings

string

应用自定义属性。

changes.file.containers[]

string

空间:drive,applicationData。

changes.file.version

integer

版本号。

changes.file.contentDownloadLink

string

文档下载链接。

changes.file.iconDownloadLink

string

图标链接。

changes.file.existThumbnail

boolean

是否有缩略图。

changes.file.thumbnailDownloadLink

string

大缩略图链接。

changes.file.smallThumbnailDownloadLink

string

小缩略图链接。

changes.file.thumbnailVersion

integer

缩略图版本号。

changes.file.onLineViewLink

string

在线浏览链接。

changes.file.createdTime

string

文件创建时间。

changes.file.editedTime

string

文件修改时间。

changes.file.editedByMeTime

string

我修改文件的时间。

changes.file.editedByMe

boolean

是否是我修改文件。

changes.file.sharedWithMeTime

string

共享给我的时间。

changes.file.sharer.category

string

类型,固定为drive#user。

changes.file.sharer.displayName

string

用户显示名。

changes.file.sharer.profilePhotoLink

string

用户头像链接(默认不返回)。

changes.file.sharer.me

boolean

是否是我。

changes.file.sharer.permissionId

string

权限id。

changes.file.sharer.userAccount

string

帐号名称(默认不返回)。

changes.file.owners.category

string

类型,固定为drive#user。

changes.file.owners.displayName

string

用户显示名。

changes.file.owners.profilePhotoLink

string

用户头像链接(默认不返回)。

changes.file.owners.me

boolean

是否是我。

changes.file.owners.permissionId

string

权限id。

changes.file.owners.userAccount

string

帐号名称(默认不返回)。

changes.file.lastEditor.category

string

类型,固定为drive#user。

changes.file.lastEditor.displayName

string

用户显示名。

changes.file.lastEditor.profilePhotoLink

string

用户头像链接(默认不返回)。

changes.file.lastEditor.me

boolean

是否是我。

changes.file.lastEditor.permissionId

string

权限id。

changes.file.lastEditor.userAccount

string

帐号名称(默认不返回)。

changes.file.hasShared

boolean

是否共享。

changes.file.ownedByMe

boolean

是否是我用。

changes.file.capabilities.addChildNodePermission

boolean

是否可以增加子目录/文件。

changes.file.capabilities.writerHasChangeCopyPermission

boolean

change copy是否需要write权限。

changes.file.capabilities.commentPermission

boolean

是否可以评论。

changes.file.capabilities.copyPermission

boolean

是否可以拷贝。

changes.file.capabilities.deletePermission

boolean

是否可以删除。

changes.file.capabilities.downloadPermission

boolean

是否可以下载内容。

changes.file.capabilities.editPermission

boolean

是否可以编辑。

changes.file.capabilities.listChildNodePermission

boolean

是否可以list子目录/文件。

changes.file.capabilities.editContentPermission

boolean

是否可以修改内容。

changes.file.capabilities.readHistoryVersionPermission

boolean

是否可以读取副本。

changes.file.capabilities.removeChildNodePermission

boolean

是否可以移动子目录。

changes.file.capabilities.renameFilePermission

boolean

是否可以重命名。

changes.file.capabilities.shareFilePermission

boolean

是否可以共享。

changes.file.capabilities.recyclePermission

boolean

是否可以移动到回收站。

changes.file.capabilities.unrecyclePermission

boolean

是否可以撤回移动子文件到回收站。

changes.file.viewersHasCopyContentPermission

boolean

浏览者是否可以拷贝内容。

changes.file.writerHasCopyPermission

boolean

拷贝是否需要writer权限。

changes.file.writersHasSharePermission

boolean

writer能否share。

changes.file.permissions[]

list

permission列表。

changes.file.permissions.category

string

类型,固定为drive#permission。

changes.file.permissions.id

string

权限ID。

changes.file.permissions.type

string

类型,[user,anyone]。

changes.file.permissions.role

string

角色,[owner,writer,commenter,reader]。

changes.file.permissions.userAccount

string

帐号名称。

changes.file.permissions.displayName

string

名称。

changes.file.permissions.expirationTime

string

失效时间。

changes.file.permissions.deleted

boolean

资源文件权限是否已删除。

changes.file.permissions.canDiscoverFile

boolean

是否允许被搜索(仅适用于anyone类型)。

changes.file.permissionIds

list

permissionId列表。

changes.file.originalFilename

string

原始文件名。

changes.file.fullFileSuffix

string

完整的文件后缀,取name第一个.后的字符串。

changes.file.fileSuffix

string

文件后缀,fullFileSuffix最后一个字符串。

changes.file.size

integer

文件大小。

changes.file.occupiedSpace

integer

实际占用空间大小。

changes.file.pictureMetadata.width

integer

照片宽度。

changes.file.pictureMetadata.height

integer

照片高度。

changes.file.pictureMetadata.location.latitude

number

纬度。

changes.file.pictureMetadata.location.longitude

number

经度。

changes.file.pictureMetadata.location.altitude

number

高度。

changes.file.pictureMetadata.exifTime

string

照片的时间,EXIF DateTime。

changes.file.pictureMetadata.cameraMaker

string

照相机制造商。

changes.file.pictureMetadata.cameraModel

string

照相机型号。

changes.file.pictureMetadata.exposureTime

number

曝光长度,单位秒。

changes.file.pictureMetadata.aperture

number

光圈,f-number。

changes.file.pictureMetadata.flashUsed

boolean

是否使用闪光灯。

changes.file.pictureMetadata.focalLength

number

焦距,毫米。

changes.file.pictureMetadata.isoSpeed

integer

ISO速度。

changes.file.pictureMetadata.meteringMode

string

测距模式。

changes.file.pictureMetadata.sensor

string

感光类型。

changes.file.pictureMetadata.exposureMode

string

曝光模式。

changes.file.pictureMetadata.colorSpace

string

色彩空间。

changes.file.pictureMetadata.whiteBalance

string

白平衡模式。

changes.file.pictureMetadata.exposureBias

number

曝光偏差,APEX值。

changes.file.pictureMetadata.maxApertureValue

number

最大光圈值,APEX value。

changes.file.pictureMetadata.lens

string

镜头。

changes.file.videoMetadata.width

integer

视频宽度。

changes.file.videoMetadata.height

integer

视频高度。

changes.file.videoMetadata.durationTime

integer

时长,毫秒。

changes.file.sha256

string

文件的sha256。

changes.file.lastHistoryVersionId

string

最新的历史记录版本ID。

changes.file.contentVersion

string

内容版本号。

响应示例

{
    "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"
}

常见错误码

错误码后4位为业务错误码,用于区分错误场景,其他业务错误码见状态码章节。

状态码

错误码

响应代码

描述

200

NA

-

成功。

400

21004001

LACK_OF_PARAM

缺少入参,请检查参数列表。

400

21004002

PARAM_INVALID

参数校验失败,请检查参数列表。

400

21004003

PARAM_VALUE_NOT_SUPPORT

无效参数,请检查参数列表。

403

21004035

INSUFFICIENT_SCOPE

Scope校验失败。

500

21055002

OUTER_SERVICE_UNAVAILABLE

外部服务不可用。

403

21074033

AGREEMENT_NOT_SIGNED

用户还未签署华为云空间用户协议,请签署协议后再进行重试。

调用示例

    public static void main(String[] args) throws IOException {
        // 设置请求地址,当前页游标和用户认证信息
        String url = "https://driveapis.cloud.huawei.com.cn/drive/v1/changes";
        String cursor = "299830100109593600";//通过 ChangesGetStartCursor API来获取当前页游标
        String access_token = "CV5OXuNUJzKnbGq9i7Oww6tO8huw4yu9MeJrxPmcfuOOmNkjdZjXzXT6dK6Z2i9yps64Vtf02T6+JXQbMMVrhQ/F/PXqFvlWrG8tJz8OwHlWB+8EuHlygw==";
        // 获取变更列表
        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();
        }
    }