Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
How can I download an image from dropbox by javaScript?

I have tried this way, but not working for me.Actually what I want is, donwload an image from dropbox and save it in a folder then show it in my UI.But I can't figure it out why this method is not working or which is the right method for downloading image from dropbox using javascript ?

// <--------------dropbox code start here------------->
  let options = {
        success: function(files) {
          console.log("files", files);
          let imageLink = files[0].link;
          var array = imageLink.split("dl=0"); 
          var splitLink=array[0];
          let finalLink=splitLink+"raw=1";
          console.log("Final Link",finalLink);

          document.getElementById("step-two-rtsp-video").style.display = "none";
          document.getElementById('output').style.display = "none";
          document.getElementById("take-picture-btn").style.display = "none";

          const newImage = document.createElement("img");
              newImage.src = finalLink;
              document
                .getElementById("uploaded-img")
                .appendChild(newImage);
          
            var path = files[0].name;
            var token = "token";
            var url = "https://api-content.dropbox.com/1/files/auto/" + path;
            var result;
            var xhr = new XMLHttpRequest();
            xhr.onreadystatechange = function() {
                if (xhr.readyState === 4 && xhr.status === 200) {
                    result = xhr.responseText;
                    console.log(result);
                }
            }

            xhr.open("GET", url, true);
            xhr.setRequestHeader("access_token", token);
            xhr.setRequestHeader("Authorization", "Bearer " + token);
            xhr.send();
            
        
         },

        cancel: function() {
          //optional
        },
          linkType: "preview", // "preview" or "direct"
          multiselect: true, // true or false
          extensions: ['.png', '.jpg'],
      };

       var button = Dropbox.createChooseButton(options);
       document.getElementById("selectingFileType").appendChild(button);


    // <--------------dropbox code end here-------------> 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Based on the Dropbox API URL with "/1/", I see you're attempting to call Dropbox API v1, which has been retired. You should use Dropbox API v2 instead.

For using Dropbox API v2 with JavaScript, I recommend using the official Dropbox API v2 JavaScript SDK. The README there has information and examples for installing and using it.

To download a file using that, you would use the filesDownload method.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!