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
feat: remove redundant language selectors from User Documentation (#98)
* docs: add information to README about bee-js submodule requirement
* fix: remove redundant language selectors from User Documentation
In most cases the Typescript / Javascript codeblock language selectors
shared the same exact code snippets.
For these cases, the redundant language selector control and duplicate
code snippets have been removed.
After that you need to import the Bee class and create a bee instance connecting to your Bee node (here we assume it runs on localhost on default port).
44
44
Be aware, if you will pass invalid URL the constructor will throw an exception!
console.log(retrievedData.text()) // prints 'Bee is awesome!'
69
44
```
70
45
71
-
</TabItem>
72
-
</Tabs>
73
-
74
46
:::info Tip
75
47
Swarm reference or hash is a 64 characters long hex string which is the address of the uploaded data, file or directory.
76
48
:::
@@ -79,28 +51,6 @@ Swarm reference or hash is a 64 characters long hex string which is the address
79
51
80
52
You can also upload files and include a filename. When you download the file, `bee-js` will return additional information like `contentType` or `name` of the file.
constresult=awaitbee.uploadFile(postageBatchId, "Bee is awesome!", "textfile.txt")
@@ -111,35 +61,8 @@ console.log(retrievedFile.contentType) // prints 'application/octet-stream'
111
61
console.log(retrievedFile.data.text()) // prints 'Bee is awesome!'
112
62
```
113
63
114
-
</TabItem>
115
-
</Tabs>
116
-
117
64
In browsers, you can upload directly `File` type. The filename is taken from the file object itself, but can be overwritten through the second argument of the `uploadFile` function (see the [API docs](../api/classes/bee.md#uploadfile))
@@ -152,39 +75,10 @@ console.log(retrievedFile.contentType) // prints 'text/plain'
152
75
console.log(retrievedFile.data.text()) // prints 'foo'
153
76
```
154
77
155
-
</TabItem>
156
-
</Tabs>
157
-
158
78
### Files and Directories
159
79
160
80
The last supported mode is upload of files and directories. In browsers, you can easily upload an array of `File` comming from your form directly as well as [`FileList`](https://developer.mozilla.org/en-US/docs/Web/API/FileList). If the files uploaded through `uploadFiles` have a relative path, they are added relative to this filepath. Otherwise, the whole structure is flattened into single directory.
@@ -199,9 +93,6 @@ console.log(rFoo.data.text()) // prints 'foo'
199
93
console.log(rBar.data.text()) // prints 'bar'
200
94
```
201
95
202
-
</TabItem>
203
-
</Tabs>
204
-
205
96
In nodejs, you may utilise the `uploadFilesFromDirectory` function, which takes directory path as input and upload all files in that directory. Lets assum we have following data structure:
206
97
207
98
```sh
@@ -211,34 +102,10 @@ In nodejs, you may utilise the `uploadFilesFromDirectory` function, which takes
constrBar=awaitbee.downloadFile(result.reference, './dir/bar.txt') // download bar
@@ -247,9 +114,6 @@ console.log(rFoo.data.text()) // prints 'foo'
247
114
console.log(rBar.data.text()) // prints 'bar'
248
115
```
249
116
250
-
</TabItem>
251
-
</Tabs>
252
-
253
117
## Retrieve file from node or gateway
254
118
255
119
You can always retrieve your files and data directly from the bee node through browser as well. For example, if you want to retrieve the "Bee is awesome!" text uploaded to Swarm in section [upload data](#data), you can directly access it with: [http://localhost:1633/files/fd79d5...294780](http://localhost:1633/files/fd79d5e0ebd8407e422f53ce1d7c4c41ebf403be55143900f8d1490560294780)
0 commit comments