首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我如何创建目录与ipfs-http-客户端与呋喃网关?

我如何创建目录与ipfs-http-客户端与呋喃网关?
EN

Stack Overflow用户
提问于 2022-02-14 15:33:31
回答 1查看 970关注 0票数 2

试图创建一个带有infura的目录。这是医生寄来的但不管用..。

代码语言:javascript
复制
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
}

使用卷发也不起作用。

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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-04-11 20:16:45

嘿,我刚才遇到了这个问题,找到了解决办法。不确定IPFS客户端是否具有此功能,但这适用于我:

代码语言:javascript
复制
const res = await axios.post("https://ipfs.infura.io:5001/api/v0/add?pin=true&wrap-with-directory=true", data, {
        headers: {
           Authorization: auth
        }
    })
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71114329

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档