# @cloudcmd/dropbox

> dropbox files and folders crud

Latest version **5.0.3** (published 2024-03-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cloudcmd/dropbox
pnpm add @cloudcmd/dropbox
yarn add @cloudcmd/dropbox
bun add @cloudcmd/dropbox
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.3 |
| Published | 2024-03-16 |
| First published | 2018-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 6 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | coderaiser |
| Keywords | dropbox, directory, read, readdir, readify, cloudcmd, file, folder, move, crud, delete, remove |

## Links

- npm: https://www.npmjs.com/package/@cloudcmd/dropbox
- Repository: https://github.com/cloudcmd/dropbox
- Homepage: http://github.com/cloudcmd/dropbox
- Issues: https://github.com/cloudcmd/dropbox/issues
- npm.io page: https://npm.io/package/@cloudcmd/dropbox

## Dependencies (6)

- [squad](https://npm.io/package/squad.md) ^3.0.0
- [dropbox](https://npm.io/package/dropbox.md) ^10.34.0
- [dropboxify](https://npm.io/package/dropboxify.md) ^3.0.0
- [try-to-catch](https://npm.io/package/try-to-catch.md) ^3.0.0
- [dropbox-stream](https://npm.io/package/dropbox-stream.md) ^3.0.0
- [string-to-stream](https://npm.io/package/string-to-stream.md) ^3.0.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 5.0.3 (latest) — 2024-03-16
- 5.0.2 — 2024-03-16
- 5.0.1 — 2024-03-16
- 5.0.0 — 2024-03-16
- 4.0.6 — 2020-07-03
- 4.0.5 — 2020-02-26
- 4.0.4 — 2019-10-16
- 4.0.3 — 2018-11-13
- 4.0.2 — 2018-11-05
- 4.0.1 — 2018-10-31
- 4.0.0 — 2018-10-31
- 3.0.1 — 2018-10-29
- 3.0.0 — 2018-10-29
- 2.1.2 — 2018-09-24
- 2.1.1 — 2018-03-05
- … 9 more at https://npm.io/package/@cloudcmd/dropbox/versions

## README

# Dropbox [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]

[NPMIMGURL]: https://img.shields.io/npm/v/@cloudcmd/dropbox.svg?style=flat
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[NPMURL]: https://npmjs.org/package/@cloudcmd/dropbox "npm"
[BuildStatusURL]: https://github.com/cloudcmd/dropbox/actions?query=workflow%3A%22Node+CI%22 "Build Status"
[BuildStatusIMGURL]: https://github.com/cloudcmd/dropbox/workflows/Node%20CI/badge.svg
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
[CoverageURL]: https://coveralls.io/github/cloudcmd/dropbox?branch=master
[CoverageIMGURL]: https://coveralls.io/repos/cloudcmd/dropbox/badge.svg?branch=master&service=github

Dropbox files and folders CRUD.

## Install

```
npm i @cloudcmd/dropbox --save
```

## API

All functions requires [token](https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/) 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

```js
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

```js
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

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

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

### createWriteStream(token, path)

- **token** - `token`
- **path** - path to file

#### Example

```js
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

```js
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

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

await remove(token, '/fileOrDir');
```

### mkdir(token, path)

create directory.

- **token** - `token`
- **path** - `string`

#### Example

```js
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

```js
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

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

await move(token, '/file1', '/file2');
```

## Related

- [readify](https://github.com/coderaiser/readify "readify") - read directory content with file attributes: size, date, owner, mode
- [flop](https://github.com/coderaiser/flop "flop") - FoLder OPerations
- [dropboxify](https://github.com/coderaiser/dropboxify "dropboxify") - read directory content from dropbox compatible way with `readify`

## License

MIT

---
_Source: https://npm.io/package/@cloudcmd/dropbox · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
