The aliyun-pds-js-sdk is the official JavaScript software development kit (SDK) for PDS. It provides methods for managing PDS resources, allowing developers to build PDS-based applications. The SDK supports basic file operations, such as upload, download, copy, shift, and delete, along with operations for Drive, Share, and Group resources. The SDK runs in browsers and Node.js environments, including Electron and Node.js services.
GitHub open source repository: https://github.com/aliyun/aliyun-pds-js-sdk/tree/0.2.11.
PDS resource overview
Resources within a
Domain:
Domain/
|-- Group & Membership # Group or team
|-- User # User
|-- Account # Account
|-- Drive # Disk (network disk)
|-- Share # Shared folder (deprecated in the latest version, use the sharing API in File instead)
|-- ShareLink # Share link
|-- File # File-related (new sharing permissions, recycle bin)2. A Group can nest another Group or a User using a Membership.
Group/
|-- Group
|-- User3. The Owner of a Drive can be a Group or a User.
4. The Owner of a Share can be a User. Share is supported only in hosting mode.
5. A File must belong to a Drive or a Share. Share is supported only in hosting mode.
Drive/ # Disk
|-- File
Share/ # Shared folder (supported only in hosting mode)
|-- File6. The File primary key differs between standard mode (StandardMode) and hosting mode (HostingMode):
* Standard mode: The key is file_id
Drive/ # Disk
|-- File (type=='folder', file_id="xxxxxxxx1") # Directory (folder)
|-- File (type=='file', file_id="xxxxxxxx2") # File
* Hosting mode: The key is file_path
Drive|Share/ # Disk/Shared folder
|-- File (type=='folder',file_path:'/abc/') # Directory (folder)
|-- File (type=='file',file_path:'/abc/1.jpg') # FileInstallation
You can run the following command to install the SDK:
npm i -S aliyun-pds-js-sdk@0.2.11Note: Make sure that Node.js is installed.
Import
(1) Use in a Vue or React project
import {PDSClient} from 'aliyun-pds-js-sdk' (2) Use in Node.js
const { PDSClient } = require('aliyun-pds-js-sdk')(3) Import using a script tag in a browser
After you install the SDK with npm, find the aliyun-pds-js-sdk.min.js file in the node_modules/aliyun-pds-js-sdk/dist/ directory. Copy this file to your static service or CDN. Then, you can import it using a script tag.
<script src="/path/to/aliyun-pds-js-sdk.min.js"></script>const { PDSClient } = window.PDS_SDKExample call
PDS API features are available as methods on an instance of the PDSClient class. To use the APIs, you must create a PDSClient instance and call its methods.
const domain_id = "your_domain_id" // For example: bj123
const config = {
token_info: {...},
api_endpoint: `https://${domain_id}.api.aliyunpds.com`,
auth_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 the
configconstructor parameter, see the PDSClient class.