试图创建一个带有infura的目录。这是医生寄来的但不管用..。
const run = async () => {
const projectId = 'xxx';
const projectSecret = 'xxx';
const auth =
'Basic ' + Buffer.from(projectId + ':' + projectSecret).toString('base64');
const ipfsClient = require('ipfs-http-client');
const client = ipfsClient.create({
host: 'ipfs.infura.io',
port: 5001,
protocol: 'https',
headers: {
authorization: auth,
},
});
var dir = await client.files.mkdir('/example')
console.log(dir);
// LOG: ipfs method not supported
}使用卷发也不起作用。
curl -X POST -u "xxx:xxx" "https://ipfs.infura.io:5001/api/v0/files/mkdir?arg=/ipfs-examples-dir"
// LOG: ipfs method not supported我错过了什么或者做错了什么?
发布于 2022-04-11 20:16:45
嘿,我刚才遇到了这个问题,找到了解决办法。不确定IPFS客户端是否具有此功能,但这适用于我:
const res = await axios.post("https://ipfs.infura.io:5001/api/v0/add?pin=true&wrap-with-directory=true", data, {
headers: {
Authorization: auth
}
})https://stackoverflow.com/questions/71114329
复制相似问题