cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Tell us what you want to see on the Community here!
Close

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

Highlighted

Download dropbox images to Netlify build folder

Explorer | Level 3

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
Highlighted

Re: Download dropbox images to Netlify build folder

Dropboxer
1 Reply 1
Highlighted

Re: Download dropbox images to Netlify build folder

Dropboxer

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?