使用JavaScript上传IPF上的对象
我试图将对象上传到IPF中,但不支持错误
输入。预期的缓冲区| readableStream | pullstream | file | array< object>获得对象
这是我的JavaScript代码:
let data = {
name: bot,
description: "",
image: "https://ipfs.infura.io/ipfs/myimagehash",
};
const client = ipfsClient({
host: "ipfs.infura.io",
port: 5001,
protocol: "https",
});
try {
const added = await client.add(data);
const url = `https://ipfs.infura.io/ipfs/${added[0].path}`;
return url;
} catch (error) {
console.log("Error uploading file: ", error);
}
I tried to upload an object into IPFS but there was an error
Input not supported. Expected Buffer|ReadableStream|PullStream|File|Array<Object> got object
this is my javascript code :
let data = {
name: bot,
description: "",
image: "https://ipfs.infura.io/ipfs/myimagehash",
};
const client = ipfsClient({
host: "ipfs.infura.io",
port: 5001,
protocol: "https",
});
try {
const added = await client.add(data);
const url = `https://ipfs.infura.io/ipfs/${added[0].path}`;
return url;
} catch (error) {
console.log("Error uploading file: ", error);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我以这种方式解决了这个问题:
ok I solved this problem this way: