1.0.2 • Published 5 months ago

@bnb-chain/greenfiled-file-handle v1.0.2

Weekly downloads
-
License
GPLv3
Repository
github
Last release
5 months ago

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/greenfiled-file-handle@0.2.1/dist/browser/umd/index.js"></script>
<script
  window.__PUBLIC_FILE_HANDLE_WASM_PATH__ = 'https://unpkg.com/@bnb-chain/greenfiled-file-handle@0.2.1/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;
})()

Full Code: https://github.com/bnb-chain/greenfield-js-sdk/blob/main/examples/nextjs/src/components/object/create/index.tsx#L63

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

7 months ago

0.2.1

8 months ago

1.0.0-alpha.0

7 months ago

0.2.2-alpha.0

8 months ago

0.2.2

7 months ago

0.2.1-alpha.0

9 months ago

0.2.0

11 months ago

0.1.0

12 months ago

0.1.0-alpha.1

12 months ago

0.1.0-alpha.0

12 months ago