File authorization

Updated at:

This document describes the methods for file authorization and sharing.

listShareFiles method

Important

Supported in standard mode.

Warning

Not supported in hosted mode.

Query a list of shared files

const result = await client.listShareFiles(params, options)

Parameters

Field

Type

Required

Description

params

IListReq

The default value is {}.

options

AxiosRequestConfig

Other configuration items.

IListReq

Field

Type

Required

Description

limit

number

The number of items to return in a single query.

marker

string

Mark

Returns

Field

Type

Required

Description

result

IListRes<IFileItem>

Yes

The result.

IListRes

Field

Type

Required

Description

items

array

Yes

A list of file information. For details about the fields for each item, see the IFileItem description.

next_marker

string

Yes

The pagination token.

punished_file_count

number

A folder is returned.

IFileItem

Field

Type

Required

Description

action_list

string[]

A list of permissions.

created_at

Date

Yes

The time when the file was created.

creator_id

string

The ID of the creator.

creator_name

string

The name of the creator.

creator_type

string

The type of the creator.

domain_id

string

Yes

The domain ID.

drive_id

string

Yes

The disk ID.

encrypt_mode

string

Indicates whether the file is shared in encrypted mode.

file_id

string

The file ID.

hidden

boolean

Show/Hide

last_modifier_id

string

The ID of the user who last modified the file.

last_modifier_name

string

The name of the user who last modified the file.

last_modifier_type

string

The type of the user who last modified the file.

name

string

The file name.

parent_file_id

string

The ID of the parent folder.

revision_id

string

Version

starred

boolean

Indicates whether the file is starred. A value of true indicates that the file is starred.

status

string

Yes

The file status. Valid values are available and enabled.

type

string

File type: Folder

updated_at

Date

Yes

The time when the file was last updated.

listReceivedShareFiles method

Important

Supported in standard mode.

Warning

Not supported in hosted mode.

This method lists the shared files that you have received.

const result = await client.listReceivedShareFiles(params, options)

Parameters

Field

Type

Required

Description

params

IListReq

The default value is {}.

options

AxiosRequestConfig

Other configuration items.

IListReq

Field

Type

Required

Description

limit

number

The number of items to return in a single query.

marker

string

Note

Returns

Field

Type

Required

Description

result

IListRes<IFileItem>

Yes

The result.

IListRes

Field

Type

Required

Description

items

array

Yes

A list of file information. For details about the fields for each item, see the IFileItem description.

next_marker

string

The pagination token.

punished_file_count

number

The folder is returned.

listManageSharingFiles method

Important

Supported in standard mode.

Warning

Not supported in hosted mode.

This method lists the sharing records that you manage.

const result = await client.listManageSharingFiles(params, options)

Parameters

Field

Type

Required

Description

params

IListReq

The query parameters. The default value is {}.

options

AxiosRequestConfig

Other configuration items.

IListReq

Field

Type

Required

Description

limit

number

The number of items to return in a single query.

marker

string

mark

Return

Field

Type

Required

Description

result

IListRes

Yes

Return result

IListRes

Field

Type

Required

Description

items

array

Yes

A list of file information. For details about the fields for each item, see the IFileItem description.

next_marker

string

The pagination token.

addFilePermission method

Important

Supported in standard mode.

Warning

Not supported in hosted mode.

This method adds or updates file permissions. You can use this operation to create or update a share.

const result = await client.addFilePermission(params, options)

Parameters

Field

Type

Required

Description

params

IAddFilePermissionReq

Yes

The information required to create the share.

options

AxiosRequestConfig

Other configuration items.

IAddFilePermissionReq

Field

Type

Required

Description

drive_id

string

Yes

The disk ID.

file_id

string

The ID of the file to share.

member_list

array

A collection of user objects to share with. For details about each item in the array, see the IPermissionStandard description.

IPermissionStandard

Field

Type

Required

Description

identity

object

Yes

An object that contains the identity_type and identity_id fields.

expire_time

number

Yes

The timestamp.

role_id

string

Yes

The role ID.

disinherit_sub_group

boolean

Yes

Indicates whether to inherit permissions for sub-teams.

Return value

In standard mode, a successful operation does not return a value. If the operation fails, an exception is thrown.

removeFilePermission method

Important

Supported in standard mode.

Warning

Not supported in hosted mode.

This method removes file permissions. You can use this operation to delete a share.

await client.removeFilePermission(params, options)

Parameters

Field

Type

Required

Description

params

IAddFilePermissionReq

Yes

The shared file to delete.

options

AxiosRequestConfig

Other configuration items.

Return value

A successful operation does not return a value. If the operation fails, an exception is thrown.

listFilePermissions method

Important

Supported in standard mode.

Warning

Not supported in hosted mode.

Retrieving members authorized for a file

const result = await client.listFilePermission(params, options)

Parameters

Field

Type

Required

Description

params

IListPermissionReq

Yes

The query parameters.

options

AxiosRequestConfig

No

Other configuration items.

IListPermissionReq

Field

Type

Required

Description

drive_id

string

Yes

The disk ID.

file_id

string

Yes

The file ID.

Return

Field

Type

Required

Description

result

array

Yes

The result. For details about each item, see the IPermissionStandard description.

IPermissionStandard

Field

Type

Required

Description

identity

object

Yes

An object that contains the identity_name, identity_type, and identity_id fields.

expire_time

number

Yes

The timestamp.

role_id

string

Yes

The role ID.

disinherit_sub_group

boolean

Yes

Indicates whether to inherit permissions for sub-teams.

listFileInheritPermissions method

Important

Supported in standard mode.

Warning

Not supported in hosted mode.

Inherited permissions from the parent folder

const result = await client.listFileInheritPermission(params, options)

Parameters

Field

Type

Required

Description

params

IListPermissionReq

Yes

options

AxiosRequestConfig

No

Other configuration items.

IListPermissionReq

Field

Type

Required

Description

drive_id

string

Yes

The disk ID.

file_id

string

Yes

The file ID.

Returns

Field

Type

Required

Description

result

IListRes

Yes

The result.

IListRes

Field

Type

Required

Description

items

IListInheritRes[]

Yes

next_marker

string

Yes

The pagination token.

IListInheritRes

Field

Type

Required

Description

member

IListPermissionRes

Yes

file_id

string

Yes

The pagination token.

IListPermissionRes

Field

Type

Required

Description

disinherit_sub_group

boolean

No

Indicates whether the permission is inherited from a parent folder.

expire_time

number

Yes

The timestamp.

role_id

string

Yes

Role ID

domain_id

string

Yes

The domain ID.

drive_id

string

Yes

The disk.

file_id

string

Yes

The file ID.

creator

string

Yes

The creator.

created_at

number

Yes

The creation time.

can_access

boolean

Yes

Indicates whether the file can be accessed.

identity

IIdentityRes

Yes

The identity information.

IIdentityRes

Field

Type

Required

Description

identity_id

string

Yes

The identity ID.

identity_name

string

No

The name.

identity_type

string

Yes

The type.

listUserPermissions method

Important

Supported in standard mode.

Warning

Not supported in hosted mode.

This method lists the permissions that are granted to a user.

const result = await client.listUserPermission(params, options)

Parameters

Field

Type

Required

Description

params

IUserPermissionReq

Yes

The query parameters.

options

AxiosRequestConfig

No

Other configuration items.

IUserPermissionReq

Field

Type

Required

Description

user_id

string

Yes

The user ID.

type

string

No

The user type. Valid values are self and group.

Returns

Field

Type

Required

Description

result

IListRes

Yes

The result.

IListRes

Field

Type

Required

Description

items

IListPermissionRes[]

Yes

For details, see the IListPermissionRes description.

next_marker

string

Yes

The pagination token.