Skip to content

Instantly share code, notes, and snippets.

@MCarlomagno
Created April 14, 2022 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MCarlomagno/26f992fbbce6cd0bb7519a901ea8c6cb to your computer and use it in GitHub Desktop.
Save MCarlomagno/26f992fbbce6cd0bb7519a901ea8c6cb to your computer and use it in GitHub Desktop.
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