Skip to content

Commit 559ff03

Browse files
committed
fix: fileToByteString docs
1 parent ea4e224 commit 559ff03

File tree

5 files changed

+30
-3
lines changed

5 files changed

+30
-3
lines changed

.changeset/rare-sheep-notice.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@zerochain/sdk': patch
3+
---
4+
5+
Export necessary TS types + fileToByteString utility

docs/docs/api/file.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ type BulkUploadOption = {
119119
remotePath: string
120120
/** Whether to encrypt the file */
121121
encrypt: boolean
122-
thumbnailBytes: number[]
122+
/** Use `fileToByteString` to generate the thumbnail byte string, or assign an empty string if unavailable. */
123+
thumbnailBytes: string
123124
/** Callback function will be invoked with progress updates */
124125
callback?: (
125126
totalBytes: number,
@@ -162,7 +163,7 @@ const result = await multiUpload({
162163
file: new File(['file content'], 'file1.txt'),
163164
remotePath: '/my-folder/file1.txt',
164165
encrypt: true,
165-
thumbnailBytes: [],
166+
thumbnailBytes: "",
166167
callback: (totalBytes, completedBytes, fileName, blobURL, error) => {
167168
console.log(`Upload progress for ${fileName}: ${completedBytes}/${totalBytes} bytes`);
168169
if (error) {

docs/docs/api/introduction.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 1
3+
title: "SDK Methods Index"
34
---
45

56
# Introduction

docs/docs/api/utility.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,22 @@ import { isDesiredWasmInitialized } from '@zerochain/sdk'
207207

208208
const isInitialized = isDesiredWasmInitialized(console.log)
209209
```
210+
211+
### `fileToByteString`
212+
Converts a JS `File` object to a byte string.
213+
214+
:::info
215+
If you want to upload a thumbnail for your file in [`multiUpload`](/docs/api/file#multiupload), you will need to add the `thumbnailBytes` param in the `BulkUploadOption` of that file. To get `thumbnailBytes`, use this method to convert the thumbnail file to a byte string.
216+
:::
217+
218+
#### Parameters
219+
220+
| Name | Type | Description | Default value |
221+
|--------|--------|---------------------------------|---------------|
222+
| `file` | `File` | The JS file object to convert to a byte string. | |
223+
224+
#### Return Type
225+
226+
```ts
227+
Promise<string>
228+
```

package/src/sdk/blobber.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ type BulkUploadOption = {
217217
remotePath: string
218218
/** Whether to encrypt the file */
219219
encrypt: boolean
220-
thumbnailBytes: number[]
220+
/** Use `fileToByteString` to generate the thumbnail byte string, or assign an empty string if unavailable. */
221+
thumbnailBytes: string
221222
/** Callback function will be invoked with progress updates */
222223
callback?: (
223224
totalBytes: number,

0 commit comments

Comments
 (0)