cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
If you know more about files sizes, you can make more informed decisions about which files you upload and then you can maximize the space in your Dropbox Basic account?

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

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

Re: Download dropbox images to Netlify build folder

Greg-DB
Dropboxer
1 Reply 1

Re: Download dropbox images to Netlify build folder

Greg-DB
Dropboxer
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?