Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
Posting image file on IPFS via nft.storage API - curl and javascript

I'm not a full-time coder and been trying to send a file to IPFS via nft.storage API. I'm trying to send image files stored in my server, not from a web form.

I used the curl function as below from my PC and it works.

curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsIn..." -H "Content-Type: image/png" --data-binary "@C:/mydoc/beerbee/beerbee-icon.png" --url "https://api.nft.storage/upload"

But, it doesn't work for the js code below. The only thing I got is the text "@home/myfolder/file.png" (not an image) whenever I access the content addressing identifier URL, such as this -> https://bafkreicpceead4w3hsrnyhvkwab233x66wpra57rwqyx5im4jikt4ety3q.ipfs.dweb.link/

document.getElementById("test").addEventListener("click", function() {
        
    var url = "https://api.nft.storage/upload";

    var xhr = new XMLHttpRequest();
    xhr.open("POST", url);
    
    xhr.setRequestHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cC....");
    xhr.setRequestHeader("Content-Type", "image/png");
    
    xhr.onreadystatechange = function () {
       if (xhr.readyState === 4) {
          console.log(xhr.status);
          console.log(xhr.responseText);
       }};

    var data = "@home/myfolder/file.png";

    xhr.send(file);
        
});
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda