cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Download dropbox images to Netlify build folder

Download dropbox images to Netlify build folder

itsjustmyron
Explorer | Level 3
Go to solution

I'm trying to retrieve images from my dropbox folder into my Jekyll build on Netlify, but the images are unreadable with the following code. I think that I'm using the wrong conversion for the contents.

dbx
  .filesListFolder({ path: "/images" })
  .then(response => {
    response.entries.forEach(entry => {
      const { name, path_lower } = entry;

      if (entry[".tag"] === "file") {
        dbx
          .filesDownload({ path: path_lower })
          .then(data => {
            const filename = path.resolve(IMAGES_DIR, name);
            const filecontents = data.fileBinary.toString("base64");

            fs.outputFile(filename, filecontents).catch(error => {
              if (error) {
                return console.log("Error: file failed to write", name, error);
              }
            });
          })
          .catch(error => {
            console.log("Error: file failed to download", name, error);
          });
      }
    });
  })

Any help will be much appreciated. Thanks.

1 Accepted Solution

Accepted Solutions
1 Reply 1

Greg-DB
Dropbox Staff
Go to solution
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?