Protocol | HTTP GET |
|---|---|
Direction | Developer server -> HUAWEI Drive server |
URL | https://driveapis.cloud.huawei.com.cn/drive/v1/files |
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Parameter | Mandatory/Optional | Type | Description |
|---|---|---|---|
queryParam | Optional | string | A query for filtering the file results by attribute. For details, please refer to the Overview section. |
orderBy | Optional | string | A list of sort keys separated by commas. The value options include createdTime, folder, editedTime, fileName, recycleTime, and size. Each key sorts in ascending order by default, but can be reversed with the desc modifier, for example, orderBy=folder,editedTime desc,fileName. If the number of files exceeds 100,000, orderBy is ignored. |
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. 1. The actual number of results returned each time may be empty or different from the value of pageSize. 2. If nextCursor exists, some results are not returned yet. 3. To obtain a fixed number of results (for example, 5), you can pass the cursor returned last time to call the file.list API for multiple times, until the specified number of results are obtained or the cursor is empty. |
cursor | Optional | 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 |
|---|---|---|---|
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?fields=* HTTP/1.1 Accept: application/json Cache-Control: no-cache Authorization: Bearer CF3NTYZSs7MRmxWyj8ssonQQxDgSPAjnDvrf+91NrpN22LdUrMA30A5Kzz0mf55sWao7e7VeLrmjQ0z2OmwPWlt3S00/L1BJppbTFhIgWb74ZBK8CFImUA==
When the status code is 200:
Parameter | Type | Description |
|---|---|---|
category | string | Resource type. The value is always drive#fileList. |
nextCursor | string | Cursor for the next page of files. It will be absent if the end of the file list has been reached. |
files[] | list | File list. |
files.category | string | Resource type. The value is always drive#file. |
files.id | string | File ID. |
files.fileName | string | File name. |
files.mimeType | string | MIME type of the file. |
files.description | string | Short description of the file. |
files.favorite | boolean | Indicates whether the file has been favorited. |
files.recycled | boolean | Indicates whether the file has been moved to the recycle bin. |
files.directlyRecycled | boolean | Indicates whether the file has been explicitly moved to the recycle bin. |
files.recyclingUser.category | string | User type. The value is always drive#user. |
files.recyclingUser.displayName | string | Display name of the user. |
files.recyclingUser.profilePhotoLink | string | Link to the user's profile picture, which is not returned by default. |
files.recyclingUser.me | boolean | Indicates whether the user is the requesting user. |
files.recyclingUser.permissionId | string | Permission ID. |
files.recyclingUser.userAccount | string | Account of the user, which is not returned by default. |
files.recycledTime | string | Time when the file is moved to the recycle bin. |
files.parentFolder[] | string | Parent folder. |
files.properties | string | Custom file properties that are universally visible. |
files.appSettings | string | Customized app attribute. |
files.containers[] | string | Spaces that contain the file. The options include drive and applicationData. |
files.version | integer | Version number of the file. |
files.contentDownloadLink | string | Link for downloading the file in a browser. |
files.iconDownloadLink | string | Link to the file's icon. |
files.existThumbnail | boolean | Indicates whether the file has a thumbnail. |
files.thumbnailDownloadLink | string | Link to the file's large thumbnail. |
files.smallThumbnailDownloadLink | string | Link to the file's small thumbnail. |
files.thumbnailVersion | integer | Thumbnail version number. |
files.onLineViewLink | string | Link to view the file online. |
files.createdTime | string | Time when the file is created. |
files.editedTime | string | Last time when the file is modified. |
files.editedByMeTime | string | Last time when the file is modified by the user. |
files.editedByMe | boolean | Indicates whether the file is modified by the user. |
files.sharedWithMeTime | string | Time when the file is shared with the user. |
files.sharer.category | string | User type. The value is always drive#user. |
files.sharer.displayName | string | Display name of the user. |
files.sharer.profilePhotoLink | string | Link to the user's profile picture, which is not returned by default. |
files.sharer.me | boolean | Indicates whether the user is the requesting user. |
files.sharer.permissionId | string | Permission ID. |
files.sharer.userAccount | string | Account of the user, which is not returned by default. |
files.owners.category | string | User type. The value is always drive#user. |
files.owners.displayName | string | Display name of the user. |
files.owners.profilePhotoLink | string | Link to the user's profile picture, which is not returned by default. |
files.owners.me | boolean | Indicates whether the user is the requesting user. |
files.owners.permissionId | string | Permission ID. |
files.owners.userAccount | string | Account of the user, which is not returned by default. |
files.lastEditor.category | string | User type. The value is always drive#user. |
files.lastEditor.displayName | string | Display name of the user. |
files.lastEditor.profilePhotoLink | string | Link to the user's profile picture, which is not returned by default. |
files.lastEditor.me | boolean | Indicates whether the user is the requesting user. |
files.lastEditor.permissionId | string | Permission ID. |
files.lastEditor.userAccount | string | Account of the user, which is not returned by default. |
files.hasShared | boolean | Indicates whether the file is shared. |
files.ownedByMe | boolean | Indicates whether the user owns the file. |
files.capabilities.addChildNodePermission | boolean | Indicates whether the current user has permission to create subfolders or files to a folder. |
files.capabilities.writerHasChangeCopyPermission | boolean | Indicates whether the current user (assuming the writer role) has permission to change or copy the file. |
files.capabilities.commentPermission | boolean | Indicates whether the current user has permission to comment on the file. |
files.capabilities.copyPermission | boolean | Indicates whether the current user has permission to copy the file. |
files.capabilities.deletePermission | boolean | Indicates whether the current user has permission to delete the file. |
files.capabilities.downloadPermission | boolean | Indicates whether the current user has permission to download the file. |
files.capabilities.editPermission | boolean | Indicates whether the current user has permission to edit the file. |
files.capabilities.listChildNodePermission | boolean | Indicates whether the current user has permission to list subfolders or files in a folder. |
files.capabilities.editContentPermission | boolean | Indicates whether the current user has permission to modify the content of the file. |
files.capabilities.readHistoryVersionPermission | boolean | Indicates whether the current user has permission to read the historical versions of the file. |
files.capabilities.removeChildNodePermission | boolean | Indicates whether the current user has permission to remove subfolders from a folder. |
files.capabilities.renameFilePermission | boolean | Indicates whether the current user has permission to rename the file. |
files.capabilities.shareFilePermission | boolean | Indicates whether the current user has permission to share the file. |
files.capabilities.recyclePermission | boolean | Indicates whether the current user has permission to move the file to the recycle bin. |
files.capabilities.unrecyclePermission | boolean | Indicates whether the current user has permission to restore the file from the recycle bin. |
files.viewersHasCopyContentPermission | boolean | Indicates whether the current user has permission to copy the content of the file. |
files.writerHasCopyPermission | boolean | Indicates whether the current user (assuming the writer role) has permission to copy the file. |
files.writersHasSharePermission | boolean | Indicates whether the current user (assuming the writer role) has permission to share the file. |
files.permissions[] | list | List of permissions for the file. |
files.permissions.category | string | Permission category. The value is always drive#permission. |
files.permissions.id | string | Permission ID. |
files.permissions.type | string | Type of the grantee, which can be user or anyone. |
files.permissions.role | string | Role granted by the permission. The options include owner, writer, commenter, and reader. |
files.permissions.userAccount | string | Account of the user. |
files.permissions.displayName | string | Display name of the permission. |
files.permissions.expirationTime | string | Time when the permission expires. |
files.permissions.deleted | boolean | Indicates whether the file permission is deleted. |
files.permissions.canDiscoverFile | boolean | Indicates whether the permission allows the file to be searched. It is applicable only to permissions of the anyone type. |
files.permissionIds | list | List of permission IDs for users with access to the file. |
files.originalFilename | string | Original file name. |
files.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. |
files.fileSuffix | string | Last component of fullFileSuffix. |
files.size | integer | File size. |
files.occupiedSpace | integer | Actual storage used by the file. |
files.pictureMetadata.width | integer | Picture width. |
files.pictureMetadata.height | integer | Picture height. |
files.pictureMetadata.location.latitude | number | Latitude stored in the picture. |
files.pictureMetadata.location.longitude | number | Longitude stored in the picture. |
files.pictureMetadata.location.altitude | number | Altitude stored in the picture. |
files.pictureMetadata.exifTime | string | Date and time when the picture is created (EXIF DateTime). |
files.pictureMetadata.cameraMaker | string | Maker of the camera that is used to create the picture. |
files.pictureMetadata.cameraModel | string | Model of the camera that is used to create the picture. |
files.pictureMetadata.exposureTime | number | Length of the exposure, in seconds. |
files.pictureMetadata.aperture | number | Aperture (f-number) used to create the picture. |
files.pictureMetadata.flashUsed | boolean | Indicates whether a flash is used to create the picture. |
files.pictureMetadata.focalLength | number | Focal length used to create the picture, in millimeters. |
files.pictureMetadata.isoSpeed | integer | ISO speed used to create the picture. |
files.pictureMetadata.meteringMode | string | Metering mode used to create the picture. |
files.pictureMetadata.sensor | string | Type of sensor used to create the picture. |
files.pictureMetadata.exposureMode | string | Exposure mode used to create the picture. |
files.pictureMetadata.colorSpace | string | Color space of the picture. |
files.pictureMetadata.whiteBalance | string | White balance mode used to create the picture. |
files.pictureMetadata.exposureBias | number | Exposure bias of the picture (APEX value). |
files.pictureMetadata.maxApertureValue | number | Maximum aperture used to create the picture (APEX value). |
files.pictureMetadata.lens | string | Lens used to create the picture. |
files.videoMetadata.width | integer | Width of the video. |
files.videoMetadata.height | integer | Height of the video. |
files.videoMetadata.durationTime | integer | Duration of the video, in milliseconds. |
files.sha256 | string | SHA-256 value for the file. |
files.lastHistoryVersionId | string | ID of the latest version. |
files.contentVersion | string | Content version number. |
HTTP/1.1 200 OK
{
"files":[
{
"fileName":"V7",
"editedByMe":true,
"description":"folder",
"owners":[
{
"permissionId":"239046878371512704",
"displayName":"*******3121@**3.com",
"me":true,
"category":"drive#user"
}
],
"hasShared":false,
"mimeType":"application/vnd.huawei-apps.folder",
"permissionIds":[
"233228122990838144"
],
"parentFolder":[
"Cp35dPknW1dpp1Ru3DdA19KRCyoO3VtRa"
],
"directlyRecycled":false,
"recycled":false,
"permissions":[
{
"role":"owner",
"deleted":false,
"id":"233228122990838144",
"category":"drive#permission",
"type":"user"
}
],
"editedByMeTime":"2020-06-04T06:10:47Z",
"createdTime":"2020-06-04T06:10:47Z",
"id":"BrVTO-YvKoTkeAFgwfYBJiq5oWUR1SqC5",
"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-04T06:10:47Z",
"writerHasCopyPermission":false,
"lastEditor":{
"permissionId":"239046878371512704",
"displayName":"*******3121@**3.com",
"me":true,
"category":"drive#user"
},
"existThumbnail":false,
"containers":[
"drive"
],
"category":"drive#file",
"favorite":false
},
{
"fileName":"W23",
"editedByMe":true,
"description":"folder",
"owners":[
{
"permissionId":"239046878371512704",
"displayName":"*******3121@**3.com",
"me":true,
"category":"drive#user"
}
],
"hasShared":false,
"mimeType":"application/vnd.huawei-apps.folder",
"permissionIds":[
"233228122990838144"
],
"parentFolder":[
"Cp35dPknW1dpp1Ru3DdA19KRCyoO3VtRa"
],
"directlyRecycled":false,
"recycled":false,
"permissions":[
{
"role":"owner",
"deleted":false,
"id":"233228122990838144",
"category":"drive#permission",
"type":"user"
}
],
"editedByMeTime":"2020-06-12T03:05:13Z",
"createdTime":"2020-06-12T03:05:13Z",
"id":"BrEiNSYdd6sEe4bx0501O8K90GvR53etB",
"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-12T03:05:13Z",
"writerHasCopyPermission":false,
"lastEditor":{
"permissionId":"239046878371512704",
"displayName":"*******3121@**3.com",
"me":true,
"category":"drive#user"
},
"existThumbnail":false,
"containers":[
"drive"
],
"category":"drive#file",
"favorite":false
}
],
"category":"drive#fileList"
} 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 | 21004001 | LACK_OF_PARAM | Input parameter is missing. Check the parameter list. |
400 | 21004002 | PARAM_INVALID | Parameter verification failed. Check the parameter list. |
400 | 21004009 | PARENTFOLDER_NOT_FOUND | The parent folder does not exist. Specify a parent folder and try again. |
403 | 21004032 | SERVICE_NOT_SUPPORT | The service is not supported. |
403 | 21004035 | INSUFFICIENT_SCOPE | Scope verification failed. |
403 | 21004036 | INSUFFICIENT_PERMISSION | Insufficient role permission. |
500 | 21005006 | SERVER_TEMP_ERROR | Server error. |
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. |
410 | 21084100 | CURSOR_EXPIRED | The cursor has expired. Obtain a new cursor. |
410 | 21084101 | TEMP_DATA_CLEARD | Temporary data has been deleted. Obtain the cursor again. |
500 | 21085002 | OUTER_SERVICE_UNAVAILABLE | Server error. |
500 | 21085006 | SERVER_TEMP_ERROR | Server error. |
public static void main(String[] args) throws IOException {
// Set the request URL and access token.
String url = "https://driveapis.cloud.huawei.com.cn/drive/v1/files";
String access_token = "CF3qCeRPLh5GzjpB3ta5UscyjQa2rZhjgFzULNJqVDmCGCJi7IjrQwG7MKmpWIHTq6PRVeYSDsTZtjMbeCoP9ReANeBzHPYRHAppt8HZAaw/3H+IiLbWzQ==";
// Obtain a list of files.
JSONObject fileInfo = filesList(url, access_token);
System.out.println(fileInfo.toJSONString());
}
private static JSONObject filesList(String url, String access_token) throws IOException {
StringBuilder stringBuilder = new StringBuilder("");
stringBuilder.append("?").append("fields=*");
stringBuilder.append("&").append("prettyPrint=true");
HttpGet httpGet = new HttpGet(url + stringBuilder);
httpGet.setHeader("Authorization","Bearer " + access_token);
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(50000).setConnectionRequestTimeout(10000)
.setSocketTimeout(50000).build();
httpGet.setConfig(requestConfig);
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();
}
}