@cloudcmd/dropbox

中文文档
5.0.3发布于 2024/03/17MITCommonJS近 30 天下载 1825

dropbox files and folders crud

原始使用文档
文档目录13 节
  1. Install
  2. API
  3. readDir(token, path[, options])
  4. readFile(token, path)
  5. writeFile(token, path, contents)
  6. createWriteStream(token, path)
  7. createReadStream(token, path)
  8. remove(token, path)
  9. mkdir(token, path)
  10. copy(token, from, to)
  11. move(token, from, to)
  12. Related
  13. License

Dropbox License NPM version Build Status Coverage Status

Dropbox files and folders CRUD.

Install

npm i @cloudcmd/dropbox --save

API

All functions requires token as first parameter

readDir(token, path[, options])

  • token - string
  • path - string
  • options - object can contain:
    • sort - sort by: name, size, date
    • order - "asc" or "desc" for ascending and descending order (default: "asc")
    • type - when "raw" returns not formatted result

Example

const sort = 'size';
const order = 'desc';
const token = 'token';
const path = '/';
const type = 'raw';

const {readDir} = require('@cloudcmd/dropbox');

const files = await readDir(token, path, {
    type,
    sort,
    order,
});

console.log(files);
// outputs
({
    path: '/',
    files: [{
        name: 'dropbox.js',
        size: 4735,
        date: 1_377_248_899_000,
        owner: 0,
        mode: 0,
    }, {
        name: 'readify.js',
        size: 3735,
        date: 1_377_248_899_000,
        owner: 0,
        mode: 0,
    }],
});

readFile(token, path)

  • token - token
  • path - path to file

Example

const {readFile} = require('@cloudcmd/dropbox');

const readStream = await readFile(token, '/dropbox.html');
readStream.pipe(process.stdout);

writeFile(token, path, contents)

  • token - token
  • path - path to file
  • contents - contents of a file

Example

const {writeFile} = require('@cloudcmd/dropbox');

await writeFile(token, '/hello.txt', 'hello');

createWriteStream(token, path)

  • token - token
  • path - path to file

Example

const {createReadStream} = require('fs');
const {createWriteStream} = require('@cloudcmd/dropbox');

const token = 'token';
const path = '/file';

const dropboxStream = createWriteStream(token, path);
const localStream = createReadStream(path);

localStream
    .pipe(dropboxStream)
    .on('error', console
        .error)
    .on('finish', console.log);

createReadStream(token, path)

  • token - token
  • path - path to file

Example

const {createWriteStream} = require('fs');
const {createReadStream} = require('@cloudcmd/dropbox');

const token = 'token';
const path = '/file';

const dropboxStream = createReadStream(path);
const localStream = createWriteStream(token, path);

dropboxStream
    .pipe(localStream)
    .on('error', console
        .error)
    .on('finish', console.log);

remove(token, path)

remove file/directory.

  • token - token
  • path - path to file

Example

const {remove} = require('@cloudcmd/dropbox');

await remove(token, '/fileOrDir');

mkdir(token, path)

create directory.

  • token - token
  • path - string

Example

const {mkdir} = require('@cloudcmd/dropbox');

await mkdir(token, '/dirname');

copy(token, from, to)

Copy file/directory to new location

  • token - token
  • from - path from
  • to - path to

Example

const {copy} = require('@cloudcmd/dropbox');

await copy(token, '/file1', '/file2');

move(token, from, to)

Move file/directory to new location

  • token - token
  • from - path from
  • to - path to

Example

const {move} = require('@cloudcmd/dropbox');

await move(token, '/file1', '/file2');
  • readify - read directory content with file attributes: size, date, owner, mode
  • flop - FoLder OPerations
  • dropboxify - read directory content from dropbox compatible way with readify

License

MIT

版本与发布记录

@cloudcmd/dropbox 共发布 24 个版本,首次发布于 2018/02/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
5.0.3latest2024/03/172 年前
5.0.22024/03/172 年前
5.0.12024/03/162 年前
5.0.02024/03/162 年前
4.0.62020/07/036 年前
4.0.52020/02/266 年前

关于 @cloudcmd/dropbox 的常见问题

@cloudcmd/dropbox 是什么?

dropbox files and folders crud

如何安装 @cloudcmd/dropbox?

在项目目录运行 npm install @cloudcmd/dropbox,或使用 pnpm add / yarn add / bun add。

@cloudcmd/dropbox 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cloudcmd__dropbox 是否存在。

@cloudcmd/dropbox 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cloudcmd/dropbox 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cloudcmd/dropbox 可以商用吗?

@cloudcmd/dropbox 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cloudcmd/dropbox 的下载量有多少?

根据 npm 官方下载统计,@cloudcmd/dropbox 在 2026/10/10 – 2026/11/08 这 30 天内被下载 1,825 次,日均约 61 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cloudcmd/dropbox 还在维护吗?

最新版本 5.0.3 发布于 2024/03/17(2 年前);至今共发布 24 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/02/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。