From 91ca10251bd7f0f342e46a04a79f9aa97b0dcfdb Mon Sep 17 00:00:00 2001
From: rrr523 <59029880+rrr523@users.noreply.github.com>
Date: Fri, 20 Oct 2023 15:43:53 +0800
Subject: [PATCH] docs: Update README (#380)
---
packages/file-handle/README.md | 41 +++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/packages/file-handle/README.md b/packages/file-handle/README.md
index b7ac81d9..b6c2fdc4 100644
--- a/packages/file-handle/README.md
+++ b/packages/file-handle/README.md
@@ -2,4 +2,43 @@
WASM module that handle file, such as `checksums` method.
-* [ ] Nodejs `checksums` need support pass Buffer
+## Usage on Nodejs
+
+```javascript
+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:
+
+```html
+
+
+```
+
+execute wasm:
+
+```javascript
+(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