Sharing
This topic describes methods for file sharing operations, such as creating, updating, deleting, and querying shares. These operations are supported only in hosting mode (HostingMode). The options parameter in the following methods is used for additional request configurations. For more information, see AxiosRequestConfig.
listShares method
Not supported in standard mode
Supported in hosting mode
This method retrieves a list of shares.
const result = await client.listShares(params, options)Parameters
Field | Type | Required | Description |
params | IListSharesReq | The default value is {}. | |
options | AxiosRequestConfig | Other configuration items. |
IListSharesReq
Field | Type | Required | Description |
limit | number | The number of records per query. Valid values: 0-100. | |
marker | string | Mark | |
creator | string | Query by sharer | |
owner | string | Query by shared recipient |
Field | Type | Required | Description |
result | IListRes | Yes | The result returned. |
IListRes
Field | Type | Required | Description |
items | IShareItem[] | Yes | A list of file information. For information about the fields of each item in the list, see the description of IShareItem. |
next_marker | string | The pagination token for the next page. |
IShareItem
Field | Type | Required | Description |
drive_id | string | Yes | The disk ID. |
domain_id | string | Yes | The domain ID. |
created_at | Date | Yes | The time when the file was created. |
updated_at | Date | Yes | The time when the file was updated. |
status | string | Yes | The file status. Valid values: available and enabled. |
creator | string | Yes | The creator. |
description | string | The description. | |
expiration | Date | The expiration time. | |
expired | boolean | Indicates whether the share has expired. | |
owner | string | Yes | The ID of the user who created the share. |
owner_type | string | Yes | The type of the user who created the share. |
permissions | string[] | The list of permissions. | |
share_file_path | string | The path of the shared file. | |
share_id | string | Yes | The share ID. |
share_name | string | Yes | The name of the shared file. |
share_policy | array | The list of operation permissions granted when sharing with others. |
listReceivedShares method
Not supported in standard mode
Supported in hosting mode
This method queries information about received shared files.
const result = await client.listReceivedShares(params, options)Parameters
Field | Type | Required | Description |
params | IListReceivedSharedsReq | The default value is {}. | |
options | AxiosRequestConfig | Other configuration items. |
IListReceivedSharedsReq
Field | Type | Required | Description |
limit | number | The number of entries to return in a single query. Valid values: 0 to 100. | |
marker | string | The marker. | |
owner | string | The user ID. |
Returns
Field | Type | Required | Description |
result | IListRes | Yes | The returned result. |
IListRes
Field | Type | Required | Description |
items | IShareItem[] | Yes | A list of file information. For information about the fields of each item, see the description of IShareItem. |
next_marker | string | The pagination token. |
createShare method
Not supported in standard mode
Supported in hosting mode
This method creates a share.
const result = await client.createShare(params, options)Parameters
Field | Type | Required | Description |
params | ICreateShareReq | Yes | The information used to create the share. |
options | AxiosRequestConfig | Other configuration items. |
ICreateShareReq
Field | Type | Required | Description |
drive_id | string | The disk ID. | |
description | string | The description. | |
expiration | Date | The expiration time. | |
owner | string | Sharer | |
permissions | string[] | The list of permissions. | |
share_file_path | string | The path of the shared file. | |
share_name | string | The name of the shared file. | |
status | string | The status is Enabled. |
Returns
Field | Type | Required | Description |
result | ICreateShareRes | Yes | The response returned on successful creation. |
ICreateShareRes
Field | Type | Required | Description |
share_id | string | Yes | The ID of the created share. |
domain_id | string | Yes | The domain ID. |
updateShare method
Not supported in standard mode
Supported in hosting mode
Update a share
const result = await client.updateShare(params, options)Parameters
Field | Type | Required | Description |
params | IUpdateShareReq | Yes | For the parameter format, see IUpdateShareReq. |
options | AxiosRequestConfig | Other configuration items. |
IUpdateShareReq
Field | Type | Required | Description |
share_id | string | Yes | The share ID. |
description | string | The description. | |
expiration | Date | The expiration time. | |
permissions | string[] | The list of permissions. | |
share_name | string | The name of the shared file. | |
status | string | Status: Enabled | |
share_policy | TSharePolicyItem[] | Additional permission configurations. |
TSharePolicyItem
Field | Type | Required | Description |
file_path | string | Yes | The path of the file or folder to which to attach permissions. |
permission_list | string[] | The list of specific permissions. | |
premission_type | string | The permission type. Valid values: allow and deny. | |
permission_inheritable | boolean | Indicates whether to inherit permissions from the parent folder. |
Returns
Field | Type | Required | Description |
result | IShareItem | Yes | Success response for an update |
deleteShare method
Not supported in standard mode
Supported in hosting mode
This method deletes or cancels a share.
await client.deleteShare(params, options)Parameters
Field | Type | Required | Description |
params | IDeleteShareReq | Yes | The information about the file to delete. |
options | AxiosRequestConfig | Other configuration items. |
IDeleteShareReq
Field | Type | Required | Description |
share_id | string | Yes | The share ID. |
Returns
If the operation is successful, no value is returned. If the operation fails, an exception is thrown.
getShare method
Not supported in standard mode
Supported in hosting mode
This method retrieves share information based on a share ID.
const result = await client.getShare(params, options)Parameters
Field | Type | Required | Description |
params | IGetShareReq | Yes | The ID to query. Example: { share_id: '123' } |
options | AxiosRequestConfig | Other configuration items. |
IGetShareReq
Field | Type | Required | Description |
share_id | string | Yes | The share ID. |
Returns
Field | Type | Required | Description |
result | IShareItem | Yes | The result. |