How to use the dropbox function in dropbox

To help you get started, we’ve selected a few dropbox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blockstack / blockstack-browser / app / js / account / utils / dropbox.js View on Github external
function uploadPhoto(api: {dropboxAccessToken: string}, identityIndex: number,
  identityAddress: string, photoFile: any, photoIndex: number): Promise<*> {
  const dbx = new Dropbox({ accessToken: api.dropboxAccessToken })
  const path = getAvatarPath(identityIndex, identityAddress, photoIndex)
  return new Promise((resolve, reject) => dbx.filesUpload({ path, contents: photoFile })
  .then((response) => {
    dbx.sharingCreateSharedLinkWithSettings({ path: response.path_lower, settings: {} })
    .then((shareLinkResponse) => {
      /* Appending dropbox share url with ?dl=1 returns the actual file
      instead of dropbox sign up page */
      const avatarUrl = `${shareLinkResponse.url.split('=')[0]}=1`

      resolve(avatarUrl)
    })
    .catch((error) => {
      reject(error)
    })
  })
  .catch((error) => {
github sallar / dropbox-fs / src / index.js View on Github external
export default ({ apiKey = null, client = null } = {}) => {
    if (!client && typeof apiKey === 'string') {
        client = new Dropbox({
            accessToken: apiKey
        });
    } else if (!client) {
        throw new Error('Dropbox client or apiKey should be provided.');
    }

    const api = {
        // fs adapter type (for downstream integrations)
        [TYPE_KEY]: 'dropbox-fs',

        /**
         * Read a directory and list all the files and folders inside
         *
         * @param {String} remotePath
         * @param {Object} options
         * @param {Function} callback
github Graphite-Docs / graphite / web / src / components / helpers / storageProviders / fetch.js View on Github external
}
  } else {
    returnedObject = {};
  }
  
  //Now, if there is an error with fetching localData we need to do a few things:
  //1: Grab the accessToken for the storage provider and use that to make the request.
  //2: If the token is expire, we need to provide a refreshToken and get a new access & refresh token.
  //3: If we got new tokens, we need to store those.
  //4: Fetch the appropriate file.
  //TODO: It would probably be smart to use IPFS as a fallback in case of file overwriting or something drastic.
  if (!returnedObject.data) {
    //Dropbox
    if (params.provider === "dropbox") {
      //Creating a Dropbox constructor with params from the method call.
      const dbx = new Dropbox({
        accessToken: params.token,
        fetch: fetch
      });
      //Make the Dropbox call here and return it to the file that's calling this function.
      return dbx
        .filesDownload({ path: params.filePath })
        .then(response => {
          console.log(response)
          return response;
        })
        .catch(error => {
          console.log(error);
          return "error fetching file";
        });
    } else if(params.provider === 'google') {
      //First we need to use the refreshToken to get a new access token.
github buttercup / buttercup-browser-extension / source / background / DropboxAuthenticator.js View on Github external
constructor(accessToken) {
        this._token = accessToken || null;
        this._client = (accessToken) ?
            new Dropbox({ accessToken }) :
            new Dropbox({
                clientId: "5fstmwjaisrt06t"
            });
    }
github blockstack / blockstack-browser / app / js / account / utils / dropbox.js View on Github external
function deleteProfile(api: {dropboxAccessToken: string}, identityIndex: number,
  identityAddress: string): Promise<*> {
  const dbx = new Dropbox({ accessToken: api.dropboxAccessToken })
  const path = getProfilePath(identityIndex, identityAddress)
  return dbx.filesDelete({ path })
}
github ayoisaiah / stellar-photos / src / App.js View on Github external
saveToDropbox(id, url) {
    this.handleShowSnackbar("Saving to Dropbox...", 500);
    const { accessToken } = this.state;
    const dropbox = new Dropbox({ accessToken });

    dropbox.filesSaveUrl({ path: `/photo-${id}.jpg`, url: url })
    .then(response => this.handleShowSnackbar("Image saved to your Dropbox successfully"))
    .catch(error => this.handleShowSnackbar("Oops an error occured. Please check your internet connection"))

  }
github blockstack / blockstack-browser / app / js / account / utils / dropbox.js View on Github external
function deletePhoto(api: {dropboxAccessToken: string}, identityIndex: number,
  identityAddress: string, photoIndex: number): Promise<*> {
  const dbx = new Dropbox({ accessToken: api.dropboxAccessToken })
  const path = getAvatarPath(identityIndex, identityAddress, photoIndex)
  return dbx.filesDelete({ path })
}
github buttercup / buttercup-browser-extension / source / setup / library / dropbox.js View on Github external
export function getClient() {
    if (!__client) {
        __client = new Dropbox({
            clientId: DROPBOX_CLIENT_ID
        });
    }
    return __client;
}

dropbox

The Dropbox JavaScript SDK is a lightweight, promise based interface to the Dropbox v2 API that works in both nodejs and browser environments.

MIT
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis