标签: ipfs

IPFS 搜索文件机制

我正在使用 IPFS(星际文件系统)以分散的方式存储文档/文件。

  • 为了从网络中搜索文件,是否有网络上所有哈希的记录(如水蛭)?
  • 我的请求如何通过网络传播?

search distributed-computing distributed-filesystem ipfs decentralized-applications

2
推荐指数
1
解决办法
1969
查看次数

生成与 IPFS-Desktop CID 匹配的 CID 的无节点方法

我想在 javascript 中为文件生成 CID(内容标识符),而无需访问 IPFS 节点或互联网。我尝试使用js-multihashing-async首先对文件进行散列,然后使用js-cid从散列生成 CID,但是我得到的 CID 与将文件添加到ipfs-desktop 不同。看起来问题出在 IPFS 节点数据块上,而 CID 用于链接文件块的 DAG。我已经尝试过这个库,但它不会产生与 ipfs-desktop 为同一个文件所做的相同的 CID。这个问题与我的问题基本相同,但没有一个答案给出与 ipfs-desktop-generated CID 匹配的 CID。

javascript sha256 ipfs

2
推荐指数
1
解决办法
1148
查看次数

如何列出 IPFS 实例的所有当前固定文件?

根据https://docs.ipfs.io/guides/concepts/pinning/,运行命令ipfs add hello.txt显然“固定”了文件“hello.txt”,但是为什么我在运行命令时没有看到后面列出的文件ipfs files ls? 它只列出我使用 IPFS 桌面应用程序添加的文件。为什么“hello.txt”现在不在列表中?

此外,我通过运行命令找到了一个所谓的“固定”对象列表ipfs pin ls,但是显示在那里的 CID 都没有对应于“hello.txt”,甚至没有任何前面提到的使用 IPFS 桌面添加的文件应用程序。

如何实际管理固定文件?

ipfs

2
推荐指数
1
解决办法
1119
查看次数

将字节数组转换为 angular6 中的图像

我已经从服务器以字节数组的形式发送了图像文件。现在我必须将其转换为jpeg文件并将其显示在网页中。

代码:

app.get('/getPhoto/:hash',function(req, res){
    console.log(req.params.hash);
    invoke = require('/Users/sanjeev.natarajan/ipfs/file1.js');

    invoke.getfile(req.params.hash).then((str)=>{
        console.log("resu",str)

        res.send({"Result":str});
    })
    .catch((error) => {
        res.send({"Error":"error in fetching the file through the hashcode"});
    })    
});
Run Code Online (Sandbox Code Playgroud)

我正在从后端接收数据;现在我需要将其转换为 angular6 中的图像

typescript ipfs angular

1
推荐指数
1
解决办法
1万
查看次数

如何在 IPFS/libp2p 中获取 WebRTC peer 的 IP 地址?

我正在使用此代码在浏览器中使用 IPFS。我想知道如何访问 webRTC 对等方的 IP 地址?甚至知道对等点实际上是 webRTC 还是 http 对等点?

<script src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.min.js"></script>

<script>
    (async () => {
        window.node = await Ipfs.create({
          config: {
            Addresses: {
              Swarm: []
            },
            Bootstrap: []
          }
        })
        window.node.libp2p.on('peer:discovery', (peer) => console.log('peer:discovery', peer))
        window.node.libp2p.on('peer:connect', peerInfo => console.log('peer:connect', peerInfo))
        window.node.libp2p.on('peer:disconnect', peerInfo => console.log('peer:disconnect', peerInfo))
        window.node.libp2p.peerStore.on('peer', (peerId) => console.log('peer', peerId))
        window.node.libp2p.peerStore.on('change:multiaddrs', ({ peerId, multiaddrs}) => console.log('change:multiaddrs', {peerId, multiaddrs}))
        window.node.libp2p.peerStore.on('change:protocols', ({ peerId, protocols}) => console.log('change:protocols', {peerId, protocols}))
        window.node.libp2p.on('error', (err) => console.log('error', err))
        window.node.libp2p.connectionManager.on('peer:connect', (connection) => console.log('peer:connect', connection))
        window.node.libp2p.connectionManager.on('peer:disconnect', (connection) …
Run Code Online (Sandbox Code Playgroud)

ipfs libp2p js-ipfs

1
推荐指数
1
解决办法
809
查看次数

使用 python 通过 Pinata API 固定目录

我正在尝试使用 pinata 的 API 来固定整个目录,正如其API 文档中所指定的那样。

我也找到了一些 python 实现,但这似乎对我来说仍然不起作用。

基本上我从目录中获取所有文件并尝试将它们包含在发布请求中。

all_files: tp.List[str] = get_all_files(filepath)            
files = {"file": [(file, open(file, "rb")) for file in all_files]}

response: requests.Response = requests.post(url=ipfs_url, files=files, headers=headers)
Run Code Online (Sandbox Code Playgroud)

我得到的错误如下:

ValueError: too many values to unpack (expected 4)
Run Code Online (Sandbox Code Playgroud)

我还尝试了一些硬编码值,但仍然没有运气:

all_files = ['images/0.png', 'images/1.png', 'images/2.png']
files = {"file": [(file, open(file, "rb")) for file in all_files]}

response: requests.Response = requests.post(url=ipfs_url, files=files, headers=headers)
Run Code Online (Sandbox Code Playgroud)

然而在这种情况下我得到了一个不同的错误:

TypeError: expected string or bytes-like object
Run Code Online (Sandbox Code Playgroud)

另外,作为另一次尝试,我尝试尝试这样的东西:

files = (
    ("file", ("0.png", open('images/0.png', "rb"))), …
Run Code Online (Sandbox Code Playgroud)

python ipfs

1
推荐指数
1
解决办法
3099
查看次数

在 javascript / typescript 中使用“fetch”对 IPFS URI 进行 API 调用(被 cors、网络错误或类型错误阻止)

我有一个在浏览器中运行的 nextjs 打字稿项目,需要发出以下fetch请求:

        const tokenURIResponse = await fetch(
            "ipfs://bafybeig37ioir76s7mg5oobetncojcm3c3hxasyd4rvid4jqhy4gkaheg4/?filename=0-PUG.json"
        )
Run Code Online (Sandbox Code Playgroud)

此调用返回一个 JSON 对象,如下所示:

{
  "name": "PUG",
  "description": "An adorable PUG pup!",
  "image": "https://ipfs.io/ipfs/QmSsYRx3LpDAb1GZQm7zZ1AuHZjfbPkD6J7s9r41xu1mf8?filename=pug.png",
  "attributes": [
    {
      "trait_type": "cuteness",
      "value": 100
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

但是,我不断收到以下错误:

勇敢的:

Unhandled Runtime Error
TypeError: Failed to fetch

Source
components/NFTBox.tsx (85:39) @ _callee$

  83 | 
  84 |         // const tokenURIResponse = await fetch(tokenURI as string)
> 85 |         const tokenURIResponse = await fetch(
     |                                       ^
  86 |             "ipfs://bafybeig37ioir76s7mg5oobetncojcm3c3hxasyd4rvid4jqhy4gkaheg4/?filename=0-PUG.json",
  87 |         )
Run Code Online (Sandbox Code Playgroud)

火狐浏览器:

Unhandled Runtime …
Run Code Online (Sandbox Code Playgroud)

javascript fetch cors typescript ipfs

1
推荐指数
1
解决办法
2067
查看次数

IPFS Swarm 和 IPFS 集群

考虑 3 个 IPFS 对等方 A、B 和 C 当对等方 A 与对等方 B 和 C 建立连接时(使用 ipfs swarm connect)

它会形成一个以 A 为领导者的集群吗?如果是,我们是否需要手动创建密钥?谁以及如何管理密钥?

ipfs

0
推荐指数
1
解决办法
1123
查看次数

运行 ipfs 守护进程时出现问题

在新计算机上安装 IPFS 并遇到运行问题:

ipfs守护进程

它返回错误:lock /Users/yenan/.ipfs/repo.lock:其他人拥有锁

这在以前的计算机上不是问题。谢谢

ipfs

0
推荐指数
1
解决办法
3478
查看次数

如何将 React 路由与 IPFS 结合使用

我正在为我的网站使用 React 路由,但在 IPFS 上它不起作用,它正在寻找不存在的路径

<Nav className="">
 <Nav.Link className="custom-link" to="/home" eventKey="1" href="/home">Home</Nav.Link>
 <Nav.Link  to="/dex" eventKey="2" href="/dex">DEX</Nav.Link>
 <Nav.Link  to="/defi" eventKey="3" >DEFI</Nav.Link>
 <Nav.Link  to="/nft" eventKey="3" >NFT</Nav.Link>
</Nav>
Run Code Online (Sandbox Code Playgroud)

路线

import {BrowserRouter,Route, Switch} from 'react-router-dom'
    <BrowserRouter>
    <Switch className ="switch">
    <Route path="/" component={Home} exact />
    <Route path="/home" component={Home} />
    <Route path="/dex" component={Dex} />
    </Switch>
    </BrowserRouter>
Run Code Online (Sandbox Code Playgroud)

一旦部署在 IPFS 上,如果我点击我得到的链接;

ipfs resolve -r /ipfs/bafybeifwqscmvkuffygd7tqioy6fusuh3q7y4xlq7d7bfhkbkrsftcruoy/dex: no link named "dex" under bafybeifwqscmvkuffygd7tqioy6fusuh3q7y4xlq7d7bfhkbkrsftcruoy
Run Code Online (Sandbox Code Playgroud)

如何让我的路由在 IPFS 上运行?

react-router ipfs

0
推荐指数
1
解决办法
1134
查看次数

请运行`npm cache clean`

我正在尝试从此处安装IPFS npm install ipfs --save ,它给我的错误是

npm ERR!tar.unpack错误读取/ media / FLASH / Tech / IPFS / ipfs

npm ERR!addLocal无法安装/ media / FLASH / Tech / IPFS / ipfs

npm ERR!Linux 4.15.0-29-通用

npm ERR!argv“ / usr / local / bin / node”“ / usr / local / bin / npm”“安装”“ ipfs”“ --save”

npm ERR!节点v6.9.2

npm ERR!npm v3.10.9

npm ERR!0字节的tarball

npm ERR!请运行npm cache clean

我尝试做,npm cache clean但是在做的同时仍然给我同样的错误npm install ipfs --save

我不知道为什么会收到此错误。以及如何避免此错误。

node.js npm ipfs

-2
推荐指数
3
解决办法
2万
查看次数