Ethereum Asked by Usamafarooq459 on August 26, 2021
I am trying to upload my file to IPFS and save its hash to my Ethereum contract but neither ipfs.add nor ipfs.files.add is working for me…
I have tried usin for loop i.e.
for await (const result of ipfs.add(this.state.buffer)) {
console.log(result);
}
and also this way:
ipfs.add(this.state.buffer, (error, ipfsHash) =>
{
console.log('Trying to add');
if(error) {
console.error(error)
return
}
})
but both of them are not working…. I’ve tried to debug my code but the control doesn’t go beyond ipfs.add line….
Any help will be highly recommended as I am not able to find any help on the internet and stuck here badly from past few hours..
ipfs.add(fileUploaded)
works for me. buffer is not required. We can load the file directly.
I am using "ipfs-http-client": "^50.1.2"
and ipfs = create({ host: "ipfs.infura.io", port: 5001, protocol: "https" });
Answered by Prem Chanth on August 26, 2021
Try replacing ipfs.add
with ipfs.files.add
.
Answered by Miroslav Nedelchev on August 26, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP