Get started with dropbox.js CDN

MIT licensed

Dropbox.js is a library for building Dropbox sync functionality into web applications.

Tags:
  • dropbox
  • files
  • sync
  • sdk
  • client
  • filesystem
  • storage

Stable version

Copied!

How to start using dropbox.js CDN


// Include Dropbox SDK
const dropbox = document.createElement('script');
dropbox.src = 'https://cdn.cdnhub.io/dropbox.js/10.34.0/Dropbox-sdk.min.js';
document.head.appendChild(dropbox);

// Wait for the SDK to load
Dropbox.init({ appKey: 'YOUR_APP_KEY' }).then(() => {
  // Create a Dropbox metadata file uploader
  const uploadFile = (file) => {
    const uploadSession = Dropbox.filesUpload({
      path: '/MyFolder/UploadedFile.txt',
      contents: file,
    });

    uploadSession.then((response) => {
      console.log('File uploaded successfully:', response.file.name);
    });
  };

  // Get a file from the user's computer
  Dropbox.filesPicker.choose({ multiSelect: false })
    .then((files) => {
      if (files.length > 0) {
        uploadFile(files[0].file);
      }
    })
    .catch((error) => {
      console.error('Error:', error);
    });
});
Copied!
Copied!
Copied!

All versions