aliyun-pds-js-sdk is an SDK for JavaScript provided by Photo and Drive Service (PDS). This SDK allows you to perform basic operations on PDS resources. Developers can use this SDK to easliy develop PDS applications. In addition to basic file operations such as upload, download, copy, move, and delete, this SDK allows you to perform basic operations on resources such as drives, shared directories, and groups. The SDK can be used in both browsers and Node.js platforms, such as Electron and Node.
GitHub repository: https://github.com/aliyun/aliyun-pds-js-sdk.
Note: Drive and Photo Service SDK for JavaScript V1.0.0 and later do not support features in hosting mode. The version of Node.js dependencies must be 16.15.0 or later.
Drive and Photo Service resources
The following structure shows the resources in a
domain:
Domain/
|-- Group # The groups or teams.
|-- User # The users.
|-- Account # The accounts.
|-- Drive # The drives.
|-- ShareLink # The sharing links.
|-- File # The file-related resources, including the new share permissions and recycle bin.A
usercan be associated with multipleaccounts. Anaccountis used by a user for logon, such as DingTalk logon.A
grouporusercan be nested in anothergroup. A user can be added to a group as amember.
Group/
|-- Group
|-- UserThe
ownerof adrivecan be agrouporuser.A
filemust belong to adrive.
Drive/ # The drive.
|-- FileInstallation
Run the following command to install aliyun-pds-js-sdk:
npm i -S aliyun-pds-js-sdkNote: Make sure that Node.js 16.15.0 or later is installed.
Import
1. Use the SDK in a Vue or React project
import {PDSClient} from 'aliyun-pds-js-sdk/browser' 2. Use the SDK in the Node.js environment
const {PDSClient} = require('aliyun-pds-js-sdk')3. Import the SDK by using the script tag in a browser
After you install the SDK by using npm, you can copy the aliyun-pds-js-sdk.umd.cjs file in the node_modules/aliyun-pds-js-sdk/dist/browser/ directory to your static server or the Alibaba Cloud CDN (CDN) service, and import the SDK by using the script tag.
<script src="/path/to/dist/browser/aliyun-pds-js-sdk.umd.cjs"></script>const { PDSClient } = window.PDS_SDKSample code
The features of Drive and Photo Service API are implemented by using the methods of the PDSClient class. To use the features, you need to create a PDSClient instance. Then, you can use the methods of the instance to call the API operations of Drive and Photo Service.
const domain_id = "The ID of the domain" // Example: bj123.
const config = {
token_info: {...},
api_endpoint: `https://${domain_id}.api.aliyunpds.com`,
}
const pds = new PDSClient(config)
let { items=[], next_marker } = await pds.listDrives({ limit:10 })
For more information about how to construct the
configparameter, see PDSClient.