cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Discuss Dropbox Developer & API

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

Display image from Dropbox to a webpage

Display image from Dropbox to a webpage

HRania
Explorer | Level 3
Go to solution

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

 

ResultResult

 

Error

errorerror

 Can anyone help me figure this out?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

[Cross-linking for reference: https://stackoverflow.com/questions/67710163/display-image-from-dropbox-to-a-webpage ]

 

I see from your StackOverflow post that you already sorted this out.

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

[Cross-linking for reference: https://stackoverflow.com/questions/67710163/display-image-from-dropbox-to-a-webpage ]

 

I see from your StackOverflow post that you already sorted this out.

HRania
Explorer | Level 3
Go to solution

Yes, Thank you

I Forgot to mention that .

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    HRania Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?