{"id":19534639,"url":"https://github.com/buttercup/dropbox-client","last_synced_at":"2025-06-21T23:33:52.807Z","repository":{"id":33383069,"uuid":"157449552","full_name":"buttercup/dropbox-client","owner":"buttercup","description":"Dropbox client library","archived":false,"fork":false,"pushed_at":"2024-06-17T08:33:41.000Z","size":592,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T01:40:46.705Z","etag":null,"topics":["client","dropbox","dropbox-api","dropbox-client","dropbox-uploader"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/buttercup.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-13T21:30:16.000Z","updated_at":"2023-07-09T10:53:07.000Z","dependencies_parsed_at":"2023-11-16T15:02:59.138Z","dependency_job_id":"f87728f3-69de-482d-bb0e-1a4a2f0f0718","html_url":"https://github.com/buttercup/dropbox-client","commit_stats":{"total_commits":127,"total_committers":3,"mean_commits":"42.333333333333336","dds":0.03937007874015752,"last_synced_commit":"5bb48cb79c9c0abf1522e3f16f3e035a8b484904"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buttercup%2Fdropbox-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buttercup%2Fdropbox-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buttercup%2Fdropbox-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buttercup%2Fdropbox-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buttercup","download_url":"https://codeload.github.com/buttercup/dropbox-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249169975,"owners_count":21223990,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","dropbox","dropbox-api","dropbox-client","dropbox-uploader"],"created_at":"2024-11-11T02:14:56.636Z","updated_at":"2025-04-26T14:35:11.124Z","avatar_url":"https://github.com/buttercup.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dropbox Client\n\u003e Dropbox client library for Buttercup\n\n[![Buttercup](https://cdn.rawgit.com/buttercup-pw/buttercup-assets/6582a033/badge/buttercup-slim.svg)](https://buttercup.pw) [![npm version](https://badge.fury.io/js/%40buttercup%2Fdropbox-client.svg)](https://www.npmjs.com/package/@buttercup/dropbox-client) ![Tests status](https://github.com/buttercup/dropbox-client/actions/workflows/test.yml/badge.svg)\n\n## About\n\nDropbox is an integral part of the Buttercup platform as it's used by a huge amount of users to store all kinds of data - including Buttercup vault files. Having a functional, portable and reliable Dropbox client interface is critical to the platform's stability, and currently the official Dropbox SDK is lacking in terms of quality and stability.\n\nThis library is a barebones HTTP client that makes requests directly to Dropbox's HTTP API using a token (handled externally - this library will not be responsible for fetching them). The result is a tiny, portable script that is reliable and simple to understand. It uses `fetch` ([cross-fetch](https://github.com/lquixada/cross-fetch)) to perform requests, which will obviously work in a reproducible fassion across environments.\n\n## Installation\n\nSimply run `npm install @buttercup/dropbox-client --save` to install.\n\nThe latest version (v2) requires an [ESM](https://nodejs.org/api/esm.html) environment to run. It is not available to standard CommonJS projects.\n\n## Usage\n\n### Authorisation\n\nYou can generate Dropbox authorisation URLs by using `generateAuthorisationURL`:\n\n```typescript\nimport { generateAuthorisationURL } from \"@buttercup/dropbox-client\";\n\nconst url = generateAuthorisationURL(\"client-id\", \"https://redir.example.com\");\n// open `url`\n```\n\n### Client\n\nUse the `DropboxClient` class to create a client interface:\n\n```typescript\nimport { generateAuthorisationURL } from \"@buttercup/dropbox-client\";\n\nconst client = new DropboxClient(\"my-token\");\n```\n\nYou can then use the `client` adapter to make requests like for directory contents:\n\n```typescript\nclient\n    .getDirectoryContents(\"/Documents\")\n    .then(contents =\u003e {\n        // [ {\n        //     name: \"My directory\",\n        //     path: \"/Documents/My directory\",\n        //     type: \"directory\"\n        // }, {\n        //     name: \"results.pdf\",\n        //     path: \"/Documents/results.pdf\",\n        //     type: \"file\"\n        // } ]\n    });\n```\n\nYou can also read and write files using `getFileContents` and `putFileContents`, respectively.\n\n### Compatibility Mode\n\nYou can enable compatibility mode for browser-based environments where CORS may break requests:\n\n```typescript\nconst client = new DropboxClient(\"my-token\", { compat: true });\n```\n\nIn some browser environments the \"CORS hack\" Content-Type header can fail, so this can be disabled by specifying `false` for the `compatCorsHack` property:\n\n```typescript\nconst client = new DropboxClient(\"my-token\", {\n    compat: true,\n    compatCorsHack: false\n});\n```\n\n### Custom Headers\n\nYou can provide custom headers to all the requests the client makes by specifying the `headers` option:\n\n```typescript\nconst client = new DropboxClient(\"my-token\", {\n    headers: {\n        // Disable the cache (works/necessary in some environments)\n        \"Cache-Control\": \"no-cache, no-store, max-age=0\"\n    }\n});\n```\n\n### Fs\n\nAn `fs`-like interface is also available:\n\n```typescript\nimport { generateAuthorisationURL } from \"@buttercup/dropbox-client\";\n\nconst client = new DropboxClient(\"my-token\");\n\nclient.fs.readdir(\"/photos\", (err, items) =\u003e {\n    // array of file names\n});\n```\n\n### Error Handling\n\nErrors while performing requests against the Dropbox API will be thrown wrapped in a [`Layerr`](https://github.com/perry-mitchell/layerr) error instance. It provides some extra properties with each error:\n\n```typescript\nimport { Layerr } from \"layerr\";\n\n// ...\n\nclient.getDirectoryContents(\"/\").catch((err) =\u003e {\n    const {\n        status,\n        statusText,\n        url\n    } = Layerr.info(err);\n\n    if (status === 403) {\n        // ...\n    }\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuttercup%2Fdropbox-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuttercup%2Fdropbox-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuttercup%2Fdropbox-client/lists"}