README
Node SDK For Vdisk
Vdisk Documentation
http://vdisk.weibo.com/developers/index.php?module=api&action=apiinfo
Usage
Install
npm install vdisksdk-node
Get the authorization url.
var OAuth2 = require("vdisksdk-node").OAuth2;
var oauth = new OAuth2(WEIPAN_APPKEY,WEIPAN_APPSECRET,WEIPAN_CALLBACK)
var url = oauth.authorize()
API
Classes
OAuth2
oauth2 client
Kind: global class
new OAuth2(app_key, app_secret, call_back_url)
Constructor
Param |
---|
app_key |
app_secret |
call_back_url |
string
oAuth2.authorize(response_type, display:, state) ⇒ Get the authorization url
Kind: instance method of OAuth2
Param | Description |
---|---|
response_type | |
display: | default/mobile/popup |
state |
oAuth2.accessToken(grant_type, code, refresh_token, cb)
Get access token
Kind: instance method of OAuth2
Param | Description |
---|---|
grant_type | authorization_code/refresh_token |
code | |
refresh_token | |
cb | 回调函数 |
Client
vdisk client
Kind: global class
- Client
- new Client(root)
- .accountInfo(access_token, cb)
- .metadata(access_token, path, cb)
- .delta(access_token, cursor, cb)
- .files(access_token, path, rev, cb)
- .revisions(access_token, path, cb)
- .saveFiles(access_token, path, files, overwrite, sha1, size, parent_rev, cb)
- .updateFiles(access_token, path, files, overwrite, sha1, size, parent_rev, cb)
- .shares(access_token, path, cancel, cb)
- .restore(access_token, path, rev, cb)
- .search(access_token, path, query, file_limit, include_deleted, cb)
- .copyRef(access_token, path, cb)
- .media(access_token, path, cb)
- .thumbnails(access_token, path, size, cb)
- .copyFiles(access_token, to_path, from_path, from_copy_ref, cb)
- .delFiles(access_token, path, cb)
- .moveFiles(access_token, from_path, to_path, cb)
- .createFolder(access_token, path, cb)
- .shareMedia(access_token, from_copy_ref, cb)
- .shareSearch(access_token, query, type, sort_order, page, page_size, cb)
new Client(root)
Constructor
Param | Description |
---|---|
root | sandbox/basic |
client.accountInfo(access_token, cb)
Get account info
Kind: instance method of Client
Param |
---|
access_token |
cb |
client.metadata(access_token, path, cb)
Get metadata 获取文件和目录信息
Kind: instance method of Client
Param |
---|
access_token |
path |
cb |
client.delta(access_token, cursor, cb)
Delta
Kind: instance method of Client
Param |
---|
access_token |
cursor |
cb |
client.files(access_token, path, rev, cb)
Get files
Kind: instance method of Client
Param |
---|
access_token |
path |
rev |
cb |
client.revisions(access_token, path, cb)
Get revisions 获得文件的历史版本
Kind: instance method of Client
Param |
---|
access_token |
path |
cb |
client.saveFiles(access_token, path, files, overwrite, sha1, size, parent_rev, cb)
Save files
Kind: instance method of Client
Param |
---|
access_token |
path |
files |
overwrite |
sha1 |
size |
parent_rev |
cb |
client.updateFiles(access_token, path, files, overwrite, sha1, size, parent_rev, cb)
Update files
Kind: instance method of Client
Param |
---|
access_token |
path |
files |
overwrite |
sha1 |
size |
parent_rev |
cb |
client.shares(access_token, path, cancel, cb)
Shares 描述创建并返回一个此分享文件的链接
Kind: instance method of Client
Param |
---|
access_token |
path |
cancel |
cb |
client.restore(access_token, path, rev, cb)
Restore 还原文件到某个版本
Kind: instance method of Client
Param |
---|
access_token |
path |
rev |
cb |
client.search(access_token, path, query, file_limit, include_deleted, cb)
Search 返回符合搜索的所有文件和目录信息。搜索权限于指定的目录路径及其下级目录
Kind: instance method of Client
Param |
---|
access_token |
path |
query |
file_limit |
include_deleted |
cb |
client.copyRef(access_token, path, cb)
Get copy_ref 创建一个可以转存此分享文件的标识字符串
Kind: instance method of Client
Param |
---|
access_token |
path |
cb |
client.media(access_token, path, cb)
Get media 获取文件下载和播放的链接
Kind: instance method of Client
Param |
---|
access_token |
path |
cb |
client.thumbnails(access_token, path, size, cb)
Get thumbnails 获取图片文件的缩略图
Kind: instance method of Client
Param | Description |
---|---|
access_token | |
path | |
size | s:60x60,m:100x100,l:640x480,xl:1027x768 |
cb |
client.copyFiles(access_token, to_path, from_path, from_copy_ref, cb)
Copy Files 复制一个对象。当前目录下的目录和文件总数不超过 10000 个时,可以执行此操作。超过此限额时,请进入更深层的目录分批操作。
Kind: instance method of Client
Param |
---|
access_token |
to_path |
from_path |
from_copy_ref |
cb |
client.delFiles(access_token, path, cb)
Delete files 删除一个对象。当前目录下的目录和文件总数不超过 10000 个时,可以执行此操作。超过此限额时,请进入更深层的目录分批操作。
Kind: instance method of Client
Param |
---|
access_token |
path |
cb |
client.moveFiles(access_token, from_path, to_path, cb)
Move files 移动一个对象,当前目录下的目录和文件总数不超过 5000 个时,可以执行此操作。超过此限额时,请进入更深层的目录分批操作
Kind: instance method of Client
Param |
---|
access_token |
from_path |
to_path |
cb |
client.createFolder(access_token, path, cb)
Create folder 创建目录. 一个目录下最多允许创建 1000 个子目录。
Kind: instance method of Client
Param |
---|
access_token |
path |
cb |
client.shareMedia(access_token, from_copy_ref, cb)
Get share media 获取分享文件下载和播放的链接
Kind: instance method of Client
Param | Description |
---|---|
access_token | |
from_copy_ref | 拷贝引用 |
cb | 回调函数 |
client.shareSearch(access_token, query, type, sort_order, page, page_size, cb)
Share search 搜索分享的文件
Kind: instance method of Client
Param | Description |
---|---|
access_token | |
query | 搜索关键词,可以传多个值,以|分隔。如query= txt|pdf|rar;按组查询时,可选doc,img,video,audio,else中一种 |
type | 搜索类型,1:全文件检索,2:按名称3:按标题,4:按描述5:按文件(夹)类型,6:按后缀,7:按组查询。 可以传多个type,如2:5:6,此时query值也以:分隔,表示各个type对应的query值,例如:query=web:doc并且type=3:7就表示查询分组是文档的并且标题中有关键字web的文件。 |
sort_order | 排序字段,可以传多个,可用的值为:sharetime(分享时间),price(价格),degree(星级),count_download(下载量),bytes(大小),可以传多个,以:分隔 |
page | 当前页数(取值范围1-40),默认1 |
page_size | 每页大小(取值范围1-9999),默认20 |
cb | 回调函数 |