We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

HRania's avatar
HRania
Explorer | Level 3
4 years ago

Display image from Dropbox to a webpage

So, I am trying to display an image on my web application. I am getting this image from a Dropbox folder. I want to get a URL I could use to show the image in HTML using the src attribute.

I have written this code:

function downloadFile() {
  var Dropbox = require('dropbox').Dropbox;
  var ACCESS_TOKEN = "XXXXXXXXXXX"; // Here the access token key
  var dbx = new Dropbox({ accessToken: ACCESS_TOKEN });

  dbx.filesDownload({ path: '/desiredImg.jpg' })
    .then(function(response) {
      var results = document.getElementById('results');
      var img = document.createElement('img');
      img.src=window.URL.createObjectURL(response.fileBlob);
      console.log(response);
      console.log(response.fileBlob);
    })
    .catch(function(error) {
      console.error(error);
    });
  return false;
}

Result

 

Result

 

Error

error

 Can anyone help me figure this out?