You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user-documentation/upload-download.md
+21-14Lines changed: 21 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,13 @@ Uploading your data to Swarm is easy with `bee-js`. Based on your needs you can
16
16
### Data
17
17
18
18
You can upload and retrieve any `string` or `Uint8Array` data with [`uploadData`](./api/classes/bee#uploaddata) and [`downloadData`](./api/classes/bee#downloaddata) functions.
19
+
20
+
When you download data the return type is [`Data`](./api/types/data) interface which extends `Uint8Array` with convenience functions like:
21
+
22
+
-`text()` that converts the bytes into UTF-8 encoded string
23
+
-`hex()` that converts the bytes into **non-prefixed** hex string
24
+
-`json()` that converts the bytes into JSON object
25
+
19
26
<Tabs
20
27
groupId="lang_preferrence"
21
28
defaultValue="ts"
@@ -34,7 +41,7 @@ console.log(hash)
34
41
35
42
const retrievedData =awaitbee.downloadData(hash)
36
43
37
-
console.log(newTextDecoder("utf-8").decode(retrievedData)) // prints 'Bee is awesome!'
44
+
console.log(retrievedData.text()) // prints 'Bee is awesome!'
38
45
```
39
46
40
47
</TabItem>
@@ -49,7 +56,7 @@ console.log(hash)
49
56
50
57
constretrievedData=awaitbee.downloadData(hash)
51
58
52
-
console.log(newTextDecoder("utf-8").decode(retrievedData)) // prints 'Bee is awesome!'
59
+
console.log(retrievedData.text()) // prints 'Bee is awesome!'
0 commit comments