Created
April 14, 2022 23:21
-
-
Save MCarlomagno/26f992fbbce6cd0bb7519a901ea8c6cb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { create } from "ipfs-http-client"; | |
async upload(file: File) { | |
this.ipfs = create({ | |
host: 'ipfs.infura.io', | |
port: 5001, | |
protocol: 'https' | |
}); | |
const blob = new Blob([file.buffer], { type: file.type }); | |
const result = await this.ipfs.add(blob); | |
// the result contains the path | |
// to the file on IPFS | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment