We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
itsjustmyron
7 years agoExplorer | Level 3
Download dropbox images to Netlify build folder
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.
[Cross-linking for reference: https://stackoverflow.com/questions/58112294/download-dropbox-images-to-netlify-build-folder ]
It looks like you already worked out the solution on StackOverflow.
1 Reply
- Greg-DB7 years ago
Dropbox Community Moderator
[Cross-linking for reference: https://stackoverflow.com/questions/58112294/download-dropbox-images-to-netlify-build-folder ]
It looks like you already worked out the solution on StackOverflow.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!