亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

IPFS 文件上傳問題

IPFS 文件上傳問題

一只斗牛犬 2022-08-27 15:09:49
我正在使用IPFS服務進行文件存儲。從 Node.js 應用程序中,我可以初始化IPFS_Node并使用此 Node 上傳文件。var ipfs = ipfsClient({            // the hostname (or ip address) of the endpoint providing the ipfs api            host: '*****************',            // the port to connect on            port: '443',            // 'api-path': '/api/v0/',            // the protocol, https for security            protocol: 'https',            // provide the jwt within an authorization header            headers: {                authorization:                    'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ**********************'            }        });    for await (const response of ipfs.add(file.buffer)) {            console.log(response);            res.json({ response: response, status: 200 });        }Ipfs 添加拋出錯誤響應HTTPError: Unauthorized   at Object.errorHandler [as handleError] (C:\Users\Rohail\Documents\GitHub\Artbot_api\node_modules\ipfs-http-client\src\lib\core.js:67:15)           at processTicksAndRejections (internal/process/task_queues.js:93:5)   at Client.fetch (C:\Users\Rohail\Documents\GitHub\Artbot_api\node_modules\ipfs-utils\src\http.js:145:9)   at Object.add (C:\Users\Rohail\Documents\GitHub\Artbot_api\node_modules\ipfs-http-client\src\add.js:13:17) { name: 'HTTPError', response: Response {   size: 0,   timeout: 0,   [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },   [Symbol(Response internals)]: {     url: 'https://api.ipfs.temporal.cloud/api/v0/add?stream-channels=true&progress=false',     status: 401,     statusText: 'Unauthorized',     headers: [Headers],     counter: 0   } }}
查看完整描述

2 回答

?
犯罪嫌疑人X

TA貢獻2080條經驗 獲得超4個贊

我發現一個錯誤,問題是ipfs-http-client版本(^ 44.0.1)。當我將其更新到最新版本(^ 44.1.1)錯誤時,錯誤已解決。

更改此設置: "ipfs-http-client": "^44.0.1"

自: "ipfs-http-client": "^44.1.1",


查看完整回答
反對 回復 2022-08-27
?
FFIVE

TA貢獻1797條經驗 獲得超6個贊

不確定這是否有幫助,但如果您使用的是最新版本 的 ,則返回而不是現在。ipfs-http-clientipfs.addAsyncIterable<Object>Promise


試試下面這些方法:


const all = require('it-all')

const data = await all(ipfs.add(file))

console.log(data)

有關詳細信息,請參閱: https://blog.ipfs.io/2020-02-01-async-await-refactor/


查看完整回答
反對 回復 2022-08-27
  • 2 回答
  • 0 關注
  • 236 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號