| 承载协议 | HTTP GET |
|---|---|
| 接口方向 | 开发者服务器->华为云空间服务器 |
| 接口URL | https://driveapis.cloud.huawei.com.cn/drive/v1/files/{fileId}/historyVersions/{historyVersionId} |
| 数据格式 | 请求消息:Content-Type: application/json 响应消息:Content-Type: application/json |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| acknowledgeDownloadRisk | 否 | boolean | 是否有下载已知恶意软件或其他滥用文件的风险。 |
| 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/files/BgZ_uIemYqVW0WYk0eNtKVYLMryFlmKjV/historyVersions/362238192574807808.362238192574807809?fields=* HTTP/1.1 Accept: application/json Authorization: Bearer CgB6e3x9DnEnu88fHJGDstSVqPOjMFJgzsth/HyitN96Fqx0PhaD1V6tTdyBvYdfewqJcD5UJXNoYknEcXwG4c7FTK+lbNT+3BSVbD3GIzAJ/Wzgn65l Cache-Control: no-cache
状态码为200时:
| 参数 | 参数类型 | 描述 |
|---|---|---|
| category | string | 类型,固定为drive#historyVersion。 |
| id | string | 历史记录ID。 |
| mimeType | string | 文件类型。 |
| editedTime | string | 修改时间。 |
| keepPermanent | boolean | 是否永久保存。 |
| lastEditor.category | string | 类型,固定为drive#user。 |
| lastEditor.displayName | string | 用户显示名。 |
| lastEditor.profilePhotoLink | string | 用户头像链接(默认不返回)。 |
| lastEditor.me | boolean | 是否是我。 |
| lastEditor.permissionId | string | 权限id。 |
| lastEditor.userAccount | string | 帐号名称(默认不返回)。 |
| originalFilename | string | 用于创建此修订版的原始文件名。此参数为初次创建文件实体时的文件名,只支持读取涉及文件实体的更新后的元数据,仅对文件元数据更新获取不到。 |
| size | integer | 文件大小。 |
| sha256 | string | 文件的sha256。 |
HTTP/1.1 200 OK
{
"editedTime": "2020-05-14T11:02:38Z",
"size": 36,
"sha256": "5b6e8d44920733d30740f5e59b9833e40d81674a02dbdfa2204165d4e338ac7d",
"lastEditor": {
"permissionId": "299639512454136576",
"displayName": "*******3121@**3.com",
"me": true,
"category": "drive#user"
},
"id": "362238192574807808.362238192574807809",
"originalFilename":"1.jpg"
"mimeType": "image/jpeg",
"category": "drive#historyVersion",
"keepPermanent": false
} 错误码后4位为业务错误码,用于区分错误场景,其他业务错误码见状态码章节。
| 状态码 | 错误码 | 响应代码 | 描述 |
|---|---|---|---|
| 200 | NA | 成功。 | |
| 400 | 21004002 | PARAM_INVALID | 输入参数错误,请检查参数列表。 |
| 403 | 21074033 | AGREEMENT_NOT_SIGNED | 用户还未签署华为云空间用户协议,请签署协议后再进行重试。。 |
| 403 | 21084031 | DATA_MIGRATING | 正处于安全策略更新, 请等待安全策略更新完成。 |
| 403 | 21084038 | OUTER_SERVICE_ERROR | 外部服务错误。 |
| 403 | 21094038 | OUTER_SERVICE_ERROR | 外部服务错误。 |
| 500 | 21085002 | OUTER_SERVICE_UNAVAILABLE | 外部服务不可用。 |
public static void main(String[] args) throws IOException {
// 设置请求地址,文件ID,历史版本ID和用户认证令牌
String url = "https://driveapis.cloud.huawei.com.cn/drive/v1/files";
String fileId = "AB0tr6O8DTQAguUs3yPFt3wQ5SDfLg04A";
String historyVersionId = "367254548466646784.367254548466646785";
String access_token = "CV5T547SEXpRlyuxqvz+PnRCtnVu784+OEIXmXAafKC+ifA3eJRnM0Ttsv20bJCkrcA+FNi4bU4nKcbERpQxlkMLQ6/Xt1iEQJYrFMyamnnI9JUV+jz4cQ==";
// 获取文件历史版版本信息
JSONObject historyVersionsInfo = historyVersionsGet(url, access_token, fileId, historyVersionId);
System.out.println(historyVersionsInfo.toJSONString());
}
private static JSONObject historyVersionsGet(String url, String access_token, String fileId, String historyVersionId) throws IOException {
StringBuilder stringBuilder = new StringBuilder("");
stringBuilder.append("/").append(fileId).append("/").append("historyVersions").append("/").append(historyVersionId);
stringBuilder.append("?").append("fields=*");
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();
}
}