首页 > 解决方案 > 如何通过 curl 在 url 中发送文件?

问题描述

我在https://i.postimg.cc/GpDskmSG/sdssds.png之类的 URL 中有一个图像,我想将其发送到 nft.storage 中。我可以直接将其作为 URL 而不是路径中的文件发送吗?我尝试了以下方法,但它只存储图像 URL。

curl -H "Authorization: Bearer eyJhbGciOiJIwetertyrtyUzI1NiIsInR5cCI6Ikp" -H "Content-Type: image/png" --data "https://i.postimg.cc/GpDskmSG/sdssds.png" --url "https://api.nft.storage/upload"

P/S:我正在测试 windows curl。

标签: httpcurlhttpshttp-headersipfs

解决方案


根据 API 文档 ( https://nft.storage/api-docs/ ),它将接受这种类型的 POST 的 multipart/form-data。

您可以尝试使用 -F/--form 代替,curl 手册页 ( https://linux.die.net/man/1/curl ) 上有一个很好的示例:

curl -F "web=@index.html;type=text/html" url.com

推荐阅读