@bnb-chain/greenfiled-file-handle
v1.0.2 greenfiled checksums
Greenfield Files JS SDK
WASM module that handle file, such as checksums
method.
Usage on Nodejs
const fs = require('fs')
const { getCheckSums } = require('@bnb-chain/greenfiled-file-handle');
const fileBuffer = fs.readFileSync('./CHANGELOG.md');
(async () => {
const { contentLength, expectCheckSums } = await getCheckSums(fileBuffer);
})()
Full Code: https://github.com/bnb-chain/greenfield-js-sdk/blob/main/examples/nodejs/storage.js
Usage on Browser
load wasm:
<script src="https://unpkg.com/@bnb-chain/[email protected]/dist/browser/umd/index.js"></script>
<script
window.__PUBLIC_FILE_HANDLE_WASM_PATH__ = 'https://unpkg.com/@bnb-chain/[email protected]/dist/node/file-handle.wasm'`,
}}
></script>
execute wasm:
(async () => {
// file is from input element
const fileBytes = await file.arrayBuffer();
const hashResult = await (window as any).FileHandle.getCheckSums(
new Uint8Array(fileBytes),
);
const { contentLength, expectCheckSums } = hashResult;
})()
npm i @bnb-chain/greenfiled-file-handle
Metadata
- GPLv3
- Whatever
- Unknown
- released 12/1/2023