--- title: Dropbox pagination_prev: demos/local/index pagination_next: demos/extensions/index ---
Dropbox is a file hosting service that offers APIs for programmatic file access. "Dropbox Apps" are the standard way to interact with the service. The ["Dropbox App"](#dropbox-app) section describes how this demo was configured. :::note The Dropbox API script is loaded in this page with ```html ``` The `data-app-key` used in this demo is a "Development" key associated with the `localhost` and `docs.sheetjs.com` domains. Dropbox API does not require "Production" approval for the Chooser or Saver. ::: The live demos require a Dropbox account. ## Reading Files "Chooser" is a small library that lets users select a file from their account. ### Live Demo The button must have the following options: - `multiselect: false` ensures only one file can be selected - `folderselect: false` limits selection to real files - `linkType: "direct"` ensures the link points to a raw file When a file is selected, the `success` callback will receive an array of files (even if `multiselect` is disabled). Each file object has a `link` file which corresponds to a temporary URL that can be fetched. :::caution If the live demo shows a message ``` ReferenceError: Dropbox is not defined ``` please refresh the page. This is a known bug in the documentation generator. ::: ```jsx live function SheetJSChoisissez() { const [msg, setMsg] = React.useState("Press the button to show a Chooser"); const btn = useRef(), tbl = useRef(); React.useEffect(() => { /* create button */ var button = Dropbox.createChooseButton({ /* required settings */ multiselect: false, folderselect: false, linkType: "direct", /* optional settings */ extensions: ['.xlsx', '.xls', '.numbers'], // list of extensions /* event handlers */ cancel: () => setMsg("User Canceled Selection!"), success: async(files) => { /* get file entry -- note that dropbox API always passes an array */ var file = files[0]; setMsg(`Selected ${file.name} ID=${file.id}`); /* fetch file and parse */ var wb = XLSX.read(await (await fetch(file.link)).arrayBuffer()); /* convert first sheet to HTML table and add to page */ tbl.current.innerHTML = XLSX.utils.sheet_to_html(wb.Sheets[wb.SheetNames[0]]); } }); /* add button to page */ btn.current.appendChild(button); }, []); return ( <>{msg}