I am currently just trying to upload a file to IPFS which I think I have been able to do as it successfully returns a CID for the file. However, when I then go to https://ipfs.io/ipfs/<CID>
I then always get a 504 Gateway timeout error
every time and I have no clue if the upload has actually been successful as I can never see the file on IPFS.
This is the console output when I run the code:
{
path: 'QmPcfLB9UPsJzh2LhACjiyWc4odWJFh9DhkxAN4UbjGxeu',
cid: CID(QmPcfLB9UPsJzh2LhACjiyWc4odWJFh9DhkxAN4UbjGxeu),
size: 119540,
mode: 420,
mtime: undefined
}
The code:
module.exports.createSBT_post = async (req, res) => {
const IPFS = await import('ipfs');
const node = await IPFS.create();
let { name, imageResult, description, grade, awardingBody, city, country, website } = req.body;
const imgBuf = Buffer.from(imageResult);
const imgResults = await node.add(imgBuf);
console.log(imgResults);
const metadata = {
"name": name,
"description": description,
"awardingBody": awardingBody,
"city": city,
"country": country,
"website": website
}
const metadataJSON = JSON.stringify(metadata);
const results = await node.add(metadataJSON);
console.log(results.cid.toString());
};
I'm not too sure what I'm doing wrong and whenever I try and find an answer online the code/examples are always outdated and the ipfs documentation is of very little help. Please can someone explain as to why I can never view my files on IPFS once they have been uploaded.
Visit an IPFS HTTP gateway and use it to download your images:
Also keep in mind IPFS can be slow to replicate - it seems to take about 10 mins when using some of the slower services.
I use Pinata's HTTP Gateway, and here's your image: https://gateway.pinata.cloud/ipfs/QmPcfLB9UPsJzh2LhACjiyWc4odWJFh9DhkxAN4UbjGxeu