-
-
Save blake41/3f3551a2d5d54db081b4004e4c311178 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var canvas = document.getElementById("canvas") | |
var dataURL = canvas.toDataURL() | |
// i then display this dataURL doing this | |
<img src="dataURL"> | |
// this works fine | |
// then i grab that same data and do | |
const buffer = Buffer.from(dataURL); | |
const ipfs = Ipfs({host: 'localhost', port: '5001', protocol: 'http'}); | |
ipfs.add(buffer) | |
.then((response) => { | |
console.log(`saved to IPFS:${response}`) | |
const hash = response[0].hash | |
this.props.contract.pushMemory(1, hash, "this is a comment on the pic", {gas: 540000, from: this.props.userAccount}).then((res) => { | |
console.log(`saved to ETH${res}`) | |
}) | |
}).catch((err) => { | |
console.error(err) | |
// reject(err); | |
}) | |
then i have the link to the ipfs hash | |
<img src="http://localhost/ipfs/ipfshash"> | |
this last img display shows it all as base64 png string of text if i load it directly in a browser tab, or as a broken image if i do it as an img tag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment