@idsync/dropbox-client

Dropbox client library

Usage no npm install needed!

<script type="module">
  import idsyncDropboxClient from 'https://cdn.skypack.dev/@idsync/dropbox-client';
</script>

README

Dropbox Client

Dropbox client library for Idsync

Installation

Simply run npm install @idsync/dropbox-client --save to install.

Usage

Use the createClient method to create a client interface:

const { createClient } = require("@idsync/dropbox-client");

const client = createClient("my-token");

You can then use the client adapter to make requests like for directory contents:

client
    .getDirectoryContents("/Documents")
    .then(contents => {
        // [ {
        //     name: "My directory",
        //     path: "/Documents/My directory",
        //     type: "directory"
        // }, {
        //     name: "results.pdf",
        //     path: "/Documents/results.pdf",
        //     type: "file"
        // } ]
    });

You can also read and write files using getFileContents and putFileContents, respectively. Check out the API documentation for more information.

Fs

An fs-like interface is also available:

const { createClient, createFsInterface } = require("@idsync/dropbox-client");

const client = createClient("my-token");
const dfs = createFsInterface(client);

dfs.readdir("/photos", (err, items) => {
    // array of file names
});

Read the fs API documentation for more information on the available methods.