@taqueria/plugin-ipfs-pinata
Version:
A plugin for Taqueria providing ipfs publishing and pinning using the Pinata service
16 lines (11 loc) • 443 B
text/typescript
import { createHash } from 'crypto';
import { readFile } from 'fs/promises';
export async function getFileIPFSHash(filePath: string): Promise<string> {
// Read the file contents
const fileContent = await readFile(filePath);
// Create a SHA-256 hash of the file contents
const hash = createHash('sha256').update(new Uint8Array(fileContent)).digest('hex');
// Return the hash as a string
return hash;
}
export default getFileIPFSHash;