Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda