我想从IPFS获得一个图像到我的Vue/Nuxt项目中。我已经通过'npm i ipfs‘导入了ipfs。但是当我运行"cont node = Ipfs.create()“时。它显示错误

但是这个错误并不总是发生,很多时候它是有效的,我可以正常地得到图像。有没有人遇到过这种情况并有解决方案?
async downloadImg () {
const node = await Ipfs.create()
const { agentVersion, id } = await node.id()
this.agentVersion = agentVersion
this.id = id
const cid = '/ipfs/QmY2dod6X7GFmqnQ6qCBiaeNxJWa3CYQaxEjGUfL5CqMAj'
// load the raw data from js-ipfs (>=0.40.0)
const bufs = []
const a = node.cat(cid)
for await (const buf of node.cat(cid)) {
bufs.push(buf)
}
const data = Buffer.concat(bufs)
const blob = new Blob([data], { type: 'image/jpg' })
this.imageSrc = window.URL.createObjectURL(blob)
},发布于 2020-10-25 09:11:40
如果我是真的,这取决于你使用的web协议,如果你使用https它的工作,而在其他协议中不!
发布于 2020-10-26 22:24:50
web加密API仅在通过https访问的页面上可用。如果您看到了该消息,您可能正在通过普通的http访问该页面。
点击堆栈跟踪顶部的github链接,了解更多解释和解决方案。
https://stackoverflow.com/questions/64516312
复制相似问题