Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Obtains a historical version of a file.
By calling the HistoryVersions.get API, your app can obtain a historical version of a file.
Protocol | HTTP GET |
|---|---|
Direction | Developer server -> HUAWEI Drive server |
URL | https://driveapis.cloud.huawei.com.cn/drive/v1/files/{fileId}/historyVersions/{historyVersionId} |
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
fileId | Mandatory | string | File ID. |
historyVersionId | Mandatory | string | ID of a historical version. |
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
acknowledgeDownloadRisk | Optional | boolean | Indicates whether a user acknowledges the download of known malware or files incurring risks. |
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 |
|---|---|---|---|
Authorization | Mandatory | string | User authorization information, that is, the access token (AT). |
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/files/BgZ_uIemYqVW0WYk0eNtKVYLMryFlmKjV/historyVersions/362238192574807808.362238192574807809?fields=* HTTP/1.1 Accept: application/json Authorization: Bearer CgB6e3x9DnEnu88fHJGDstSVqPOjMFJgzsth/HyitN96Fqx0PhaD1V6tTdyBvYdfewqJcD5UJXNoYknEcXwG4c7FTK+lbNT+3BSVbD3GIzAJ/Wzgn65l Cache-Control: no-cache
When the status code is 200:
Parameter | Type | Description |
|---|---|---|
category | string | Resource category. The value is always drive#historyVersion. |
id | string | ID of a historical version. |
mimeType | string | MIME type of the file. |
editedTime | string | Last time when a historical version is modified. |
keepPermanent | boolean | Indicates whether a historical version will be permanently kept. |
lastEditor.category | string | User type. The value is always drive#user. |
lastEditor.displayName | string | Display name of the user. |
lastEditor.profilePhotoLink | string | Link to the user's profile picture, which is not returned by default. |
lastEditor.me | boolean | Indicates whether the user is the requesting user. |
lastEditor.permissionId | string | Permission ID. |
lastEditor.userAccount | string | Account of the user, which is not returned by default. |
originalFilename | string | Original file name of a historical version. This parameter specifies the file name used when the file entity is created for the first time. The value can be obtained only when the metadata involves file entity updates. |
size | integer | File size. |
sha256 | string | SHA-256 value for the file. |
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
} The last four digits in the result code indicate the service error code, which is used to differentiate error scenarios. For details about other service error codes, please refer to Status Codes.
Status Code | Result Code | Response Code | Description |
|---|---|---|---|
200 | NA | Success. | |
400 | 21004002 | PARAM_INVALID | Invalid input parameter. Check the parameter list. |
403 | 21074033 | AGREEMENT_NOT_SIGNED | The HUAWEI Drive user agreement is not signed. Try again after the agreement is signed. |
403 | 21084031 | DATA_MIGRATINT | The security policy is being updated. Please wait until the update is complete. |
403 | 21084038 | OUTER_SERVICE_ERROR | External service error. |
403 | 21094038 | OUTER_SERVICE_ERROR | External service error. |
500 | 21085002 | OUTER_SERVICE_UNAVAILABLE | External service is unavailable. |
public static void main(String[] args) throws IOException {
// Set the request URL, file ID, historical version ID, and access token.
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==";
// Obtain a historical file version.
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();
}
}