-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hosted Service IPFS Node errors #78
Comments
Code to pin: const ipfsHttpClient = require('ipfs-http-client')
const createIpfsClient = node => {
let url
try {
url = new URL(node)
} catch (e) {
throw new Error(`Invalid IPFS URL: ${node}
The URL must be of the following format: http(s)://host[:port]/[path]`)
}
// Set the port to 443 or 80 explicitly, if no port was provided
let port = url.port
? url.port
: url.protocol === 'https:'
? 443
: url.protocol === 'http'
? 80
: undefined
// Connect to the IPFS node (if a node address was provided)
return ipfsHttpClient({
protocol: url.protocol.replace(/[:]+$/, ''),
host: url.hostname,
port: port,
'api-path': url.pathname.replace(/\/$/, '') + '/api/v0/',
})
}
export default createIpfsClient const ipfs = createIpfsClient("https://api.thegraph.com/ipfs/")
await ipfs.pin.add(hash) |
This might be related: ipfs/boxo#85 |
I'm not sure where you got that code, but this one works: const { create } = require('ipfs-http-client')
async function main() {
const client = create('https://api.thegraph.com/ipfs/api/v0')
const { cid } = await client.add('hello')
await client.pin.add(cid)
console.log(cid)
}
main() Package: "dependencies": {
"ipfs-http-client": "^50.1.2"
} |
this repo contains that code block. https://github.com/graphprotocol/ipfs-sync/blob/master/src/commands/sync-files.js |
Just tried running the sync from repo above, works as well: npm install -g @graphprotocol/ipfs-sync
echo QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN > file-list
docker run --rm -it -d -p 5001:5001 ipfs/go-ipfs:v0.4.23
ipfs-sync sync-files --from https://api.thegraph.com/ipfs --to http://localhost:5001 --file-list file-list
ipfs-sync sync-files --from http://localhost --to https://api.thegraph.com/ipfs --file-list file-list |
The sync script only works for |
i updated npm package version and tried your code. it worked. thanks! |
Nice |
I think @promaty fixed this. So reassigning & closing. |
When trying to pin a file to one of our nodes, the following error is reported:
Reported on Discord
The text was updated successfully, but these errors were encountered: