如何使用带有 infura 网关的 ipfs-http-client 创建目录?

how do i create directory with ipfs-http-client with infura gateway?

正在尝试使用 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 也不起作用

curl -X POST -u "xxx:xxx" "https://ipfs.infura.io:5001/api/v0/files/mkdir?arg=/ipfs-examples-dir"
// LOG: ipfs method not supported

我错过了什么或做错了什么?

嘿,我 运行 不久前就遇到过这个问题,并找到了解决方案。不确定 IPFS HTTP 客户端是否具有该功能,但这对我有用:

const res = await axios.post("https://ipfs.infura.io:5001/api/v0/add?pin=true&wrap-with-directory=true", data, {
        headers: {
           Authorization: auth
        }
    })