Finding cid number for dedicated sub-domain in ipfs

How to get cid number for dedicated sub-domain?

I am getting errors like
invalid ipfs path: invalid path “/ipfs/subdomain-name/ipfs/ipfs_hash”: invalid CID: expected 1 as the cid version number, got: 91

After giving cid = 1, I am getting Invalid CID
User Has Not Pinned This Content.
but I have enabled pin in my settings. Also I can see pinned items in explorer also.
Please help.

Hey, @Priyo_Chatterjee

Thanks for reaching out. Any chance you can share more lines of your code or a repo we can look at? Could you also please share some IPFS CID examples as well as some IPFS viewing URLs as well? We can attempt reproduce some errors on our end.

Kind regards,
Alex | Infura Support

Hi,
Sorry for the delay. I am using the following code:

const auth = 'Basic ’ + Buffer.from(projectId + ‘:’ + projectSecret).toString(‘base64’);
request.post({url:‘https://ipfs.infura.io:5001/api/v0/add’, headers:{Authorization:auth}, formData: formData}, function optionalCallback(err, httpResponse, body) {
resolve(“0x”+JSON.parse(body).Hash.toString(‘hex’));
})

It is working fine. I am able to get the hash back. But most of the time, it is showing 504 Gateway-time-out while accessing, in other times it is taking around 1 min time to open for first time.
Example url:
https://ipfs.io/ipfs/QmVw7C7FDQXfPTiLLLR5jqMySreCSxYMhjk3gTGEDUbDG8
https://ipfs.io/ipfs/QmeSWsPmE9E3dZ2cHU5NEfSiCxSoaHKMBa61MYnMjs3nDm
https://ipfs.io/ipfs/QmWKjagZ8QRVUGjKidittnH8aYhFVKQ3EeoNkTtm7cRs7z

SUB-DOMAIN CASE:
When I am replacing the url with the following, I am getting error - SyntaxError: Unexpected token i in JSON at position 0 —> in JSON.parse(body).

request.post({url:‘https://domain-name.ipfs.infura-ipfs.io:5001/api/v1/add’, headers:{Authorization:auth}, formData: formData}, function optionalCallback(err, httpResponse, body)

Also, what is the url to access in sub-domain scenario? Does the gateway - timeout problem gets solved by using dedicated sub-domain? Please help

Hey, @Priyo_Chatterjee

This is not correct?
request.post({url:‘https://domain-name.ipfs.infura-ipfs.io:5001/api/v1/add’, headers:{Authorization:auth}, formData: formData}, function optionalCallback(err, httpResponse, body)

You should always access the API at the URL shown in your project settings, like:
https://ipfs.infura.io:5001/etc/etc

Then you can use a gateway, like ipfs.io, to retrieve them. Even better use an Infura dedicated gateway as shown on your project settings, like:
https://somename.infura-ipfs.io/ipfs/

You will find it takes time to add a file to one IPFS node (or service like Infura), and then have it propagate across the network to another node (or public gateway like ipfs.io/ipfs/etc). Note ipfs.io is not managed by Infura but by the global IPFS community. However I am finding that my files, pinned to my Infura/IPFS project, are retrievable from a public gateway like ipfs.io or https://cloudflare-ipfs.com/ipfs/, after a short delay to allow replication.

My recommendation set up a dedicated gateway:

Warm regards,
Chris | Infura | ConsenSys

Hi Chris,

But most of the time, it is showing 504 Gateway-time-out, whenever I am trying to access. What is the use of IPFS, if I can’t retrieve my file ? I have attached example ipfs urls also. Have you seen any improvement in retrieving after using dedicated gateway?

Hi @Priyo_Chatterjee, yes huge improvement using a dedicated gateway.

1 Like