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

202
Views
Publicación de un archivo de imagen en IPFS a través de la API nft.storage - curl y javascript

No soy programador a tiempo completo y he intentado enviar un archivo a IPFS a través de la API nft.storage. Estoy tratando de enviar archivos de imagen almacenados en mi servidor, no desde un formulario web.

Usé la función curl como se muestra a continuación desde mi PC y funciona.

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

Pero, no funciona para el código js a continuación. Lo único que obtuve es el texto "@home/myfolder/file.png" (no una imagen) cada vez que accedo a la URL del identificador de direccionamiento de contenido, como este -> 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
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!