This topic describes the operations that can be performed on Drive and Photo Service drives such as creating, updating, reading, and deleting drives. This topic also provides a series of examples on how to call SDK methods of Drive and Photo Service.
The options parameter of the IPDSRequestConfig type is encapsulated based on the request config options of axios. For more information, see AxiosRequestConfig.
getQuota method
Queries the remaining space.
const result = await client.getQuota(options)Example
const {
size_quota,
size_used,
user_count_quota,
user_count_used
} = await client.getQuota()Request parameters
Parameter | Type | Required | Description |
options | IPDSRequestConfig | Other request parameters. |
Response parameter
Parameter | Type | Required | Description |
result | IQuotaRes | The returned result. |
IQuotaRes parameters
Parameter | Type | Description |
size_quota | number | The total space that is purchased. |
size_used | number | The space that is occupied. |
user_count_quota | number | The total number of users who can use this drive. |
user_count_used | number | The number of existing users. |
createDrive method
Creates a drive.
const result = await client.createDrive(params, options)Example
const { drive_id } = await client.createDrive({
drive_name: 'my_drive', // The drive name.
owner: 'xxxxx', // The user ID.
})Request parameters
Parameter | Type | Required | Description |
params | ICreateDriveReq | Yes | The parameters that are used to create the drive. |
options | IPDSRequestConfig | Other request parameters. |
ICreateDriveReq parameters
Parameter | Type | Required | Description |
default | boolean | Specifies whether to set the drive as the default drive. This parameter takes effect only in standard mode. Each user can set only one default drive. Default value: | |
drive_name | string | Yes | The drive name. |
owner | string | Yes | The ID of the |
owner_type | string | The type of the drive owner. Valid values: | |
description | string | The description. | |
total_size | number | Yes | The total storage size of the drive. Unit: |
Response parameter
Parameter | Type | Required | Description |
result | ICreateDriveRes | Yes | The message returned if the drive is created. |
ICreateDriveRes parameters
Parameter | Type | Required | Description |
drive_id | string | Yes | The drive ID. |
domain_id | string | Yes | The domain ID. |
updateDrive method
Updates the information about a drive.
const result = await client.updateDrive(params, options)Request parameters
Parameter | Type | Required | Description |
params | IUpdateDriveReq | Yes | The parameters that are used to update the information about a drive. |
options | IPDSRequestConfig | Other request parameters. |
IUpdateDriveReq parameters
Parameter | Type | Required | Description |
drive_id | string | Yes | The ID of the drive to be updated. |
description | string | The description of the drive. | |
total_size | string | The total size of the drive to be updated. Unit: | |
drive_name | string | The drive name. | |
status | string | The status of the drive. Valid values: Default value: |
Response parameter
Parameter | Type | Required | Description |
result | IDriveItem | Yes | The updated information about the drive. |
IDriveItem parameters
Parameter | Type | Required | Description |
drive_id | string | Yes | The drive ID. |
domain_id | string | Yes | The ID of the domain to which the drive belongs. |
creator | string | Yes | The ID of the user who created the drive. |
drive_name | string | Yes | The drive name. |
owner_type | string | Yes | The type of the drive owner. Valid values: |
drive_type | string | Yes | The type of the drive. Valid values: |
owner | string | Yes | The ID of the |
status | string | Yes | The status of the drive. Valid values: |
total_size | number | Yes | The total size of the drive. Unit: |
used_size | number | Yes | The size that is occupied. Unit: |
description | string | Yes | The description of the drive. |
created_at | Date | Yes | The time when the drive was created. |
subdomain_id | string | The subdomain ID. This parameter is available only if the domain has a subdomain. |
deleteDrive method
Deletes a drive.
await client.deleteDrive(params, options)Request parameters
Parameter | Type | Required | Description |
params | object | Yes | The ID of the drive to be deleted. Example: |
options | IPDSRequestConfig | No | Other request parameters. |
params parameter
Parameter | Type | Required | Description |
drive_id | string | Yes | The ID of the drive to be deleted. |
Response parameter
If the drive is deleted, no value is returned. If the drive fails to be deleted, an exception is thrown. You can analyze the cause based on the exception information.
getDrive method
Queries the details of a drive by using the drive ID.
const result = await client.getDrive(params, options)Example
const drive_id = '123'
const result = await client.getDrive({drive_id})
assert(result.drive_id==drive_id) // trueRequest parameters
Parameter | Type | Required | Description |
params | object | Yes | The ID of the drive that you want to query. Example: |
options | IPDSRequestConfig | Other request parameters. |
Response parameter
Parameter | Type | Required | Description |
result | IDriveItem | Yes | The returned result. |
searchDrives method
Queries drive information by using specific fields in fuzzy mode.
const result = await client.searchDrives(params, options)Request parameters
Parameter | Type | Required | Description |
params | ISearchDrivesReq | The parameters that are used to query drive information. Default value: {}. | |
options | IPDSRequestConfig | Other request parameters. |
ISearchDriveReq parameters
Parameter | Type | Required | Description |
drive_name | string | The drive name. | |
limit | number | The maximum number of entries to return. Valid values: 1 to 100. Default value: 100. | |
marker | string | The start marker of the query. | |
owner_type | string | The type of the drive owner. Valid values: |
Response parameter
Parameter | Type | Required | Description |
result | IListRes | Yes | The returned result. |
IListRes parameters
Parameter | Type | Required | Description |
items | IDriveItemRes[] | Yes | The queried drive information. |
next_marker | string | The marker that is used to retrieve the next page. |
listDrives method
Queries a list of drives of a user.
const result = await client.listDrives(params, options)Request parameters
Parameter | Type | Required | Description |
params | IListDrivesReq | The parameters that are used to query drives. If you do not specify this parameter, the default value {} is used. | |
options | IPDSRequestConfig | Other request parameters. |
IListDrivesReq parameters
Parameter | Type | Required | Description |
limit | string | The maximum number of entries to return. Valid values: 1 to 100. Default value: 100. | |
marker | string | The start marker of the query. | |
owner_type | string | The type of the drive owner. Value range | |
owner | string | The ID of the |
Response parameter
Parameter | Type | Required | Description |
result | IListRes | Yes | The returned result. |
IListRes parameters
Parameter | Type | Required | Description |
items | IDriveItemRes[] | Yes | The queried drive information. For information about the fields of the |
next_marker | string | The marker that is used to retrieve the next page. |
listMyDrives method
Queries a list of drives of the current user.
const result = await client.listMyDrives(params, options)Request parameters
Parameter | Type | Required | Description |
params | object | The parameters that are used to query drives. If you do not specify this parameter, the default value {} is used. | |
options | IPDSRequestConfig | Other request parameters. |
params parameters
Parameter | Type | Required | Description |
limit | string | The maximum number of entries to return. Valid values: 1 to 100. Default value: 100. | |
marker | string | The start marker of the query. |
Response parameter
Parameter | Type | Required | Description |
result | IListRes | Yes | The returned result. |
IListRes parameters
Parameter | Type | Required | Description |
items | IDriveItemRes[] | Yes | The queried drive information. |
next_marker | string | The marker that is used to retrieve the next page. |
listMyGroupDrives method
Queries the drive information of the group to which the current user belongs.
const result = await client.listMyGroupDrives(params, options) Request parameters
Parameter | Type | Required | Description |
params | IListReq | The parameters that are used to query drive information. If you do not specify this parameter, the default value {} is used. | |
options | IPDSRequestConfig | Other request parameters. |
IListReq parameters
Parameter | Type | Required | Description |
limit | string | The maximum number of entries to return. Valid values: 1 to 100. Default value: 100. | |
marker | string | The start marker of the query. |
Response parameter
Parameter | Type | Required | Description |
result | IListRes | Yes | The returned result. |
IListRes parameters
Parameter | Type | Required | Description |
items | IDriveItemRes[] | Yes | The queried drive information. |
next_marker | string | The marker that is used to retrieve the next page. |