curl请求IPFS获取API添加字节到下载文件的标题

发布于 2025-02-14 01:32:42 字数 677 浏览 0 评论 0原文

我在Linux盒上有一个IPFS节点。如果我使用:

ipfs get QmYqGwoiuw47cLhrtQ5yg1TnS6n2ekcLSZZt35gGestTuo

在命令行,下载了IPFS映像(PNG)。

但是,当我使用curl键入等效端点时:

curl --location --request POST 'http://127.0.0.1:5001/api/v0/get?arg=QmYqGwoiuw47cLhrtQ5yg1TnS6n2ekcLSZZt35gGestTuo' --output QmYqGwoiuw47cLhrtQ5yg1TnS6n2ekcLSZZt35gGestTuo

下载的文件是相同的,除了它在文件开始时具有一些字节。

这些出现在文件顶部的``PNG标识符''之前。 (似乎是CID,然后是一些nullstrings,然后一些数字)

在我的帖子请求中我做错了什么可以正确下载文件?由于当前使用卷曲下载的文件是无法使用的。

I have an IPFS node on an linux box. If i use:

ipfs get QmYqGwoiuw47cLhrtQ5yg1TnS6n2ekcLSZZt35gGestTuo

at command line the ipfs image (a png) is downloaded and usable.

However when i hit the equivalent endpoint using CURL:

curl --location --request POST 'http://127.0.0.1:5001/api/v0/get?arg=QmYqGwoiuw47cLhrtQ5yg1TnS6n2ekcLSZZt35gGestTuo' --output QmYqGwoiuw47cLhrtQ5yg1TnS6n2ekcLSZZt35gGestTuo

The file downloaded is identical except it has some bytes at the start of the file.

enter image description here

These appear before the �PNG identifier at the top of the file. (Appears to be the CID followed by some nullstrings then some numbers)

Is there anything i'm doing wrong in my post request to download the file correctly? As currently the files downloaded using CURL are unusable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终止放荡 2025-02-21 01:32:42

<

/api/v0/get

下载IPFS对象。

您可能想要的是 cat

/api/v0/cat

显示IPFS对象数据。

示例:

curl --location --request POST 'http://127.0.0.1:5001/api/v0/cat?arg=QmYqGwoiuw47cLhrtQ5yg1TnS6n2ekcLSZZt35gGestTuo' --output QmYqGwoiuw47cLhrtQ5yg1TnS6n2ekcLSZZt35gGestTuo

输出标题:

“

get is used to get IPFS objects:

/api/v0/get

Download IPFS objects.

What you likely want is cat:

/api/v0/cat

Show IPFS object data.

Example:

curl --location --request POST 'http://127.0.0.1:5001/api/v0/cat?arg=QmYqGwoiuw47cLhrtQ5yg1TnS6n2ekcLSZZt35gGestTuo' --output QmYqGwoiuw47cLhrtQ5yg1TnS6n2ekcLSZZt35gGestTuo

Header of output:

PNG header

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文