This repository was archived by the owner on Mar 10, 2020. It is now read-only.
Commit e5d90e2
docs: add note about ipfs.types.Buffer (#373)
I've spent an hour trying to figure out how to do `ipfs add` in the browser: docs describe the "Buffer" part really vaguely and don't mention that `ipfs.files.add` in fact creates a directory object unless used with a correctly created buffer. It works with an incorrectly created buffer, but creates a directory with auto-generated name:
```js
let data = new Uint8Array([0x41, 0x42, 0x43]);
let results = await ipfs.files.add(data);
```
Here `results` is
```json
[
{
"path": "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn",
"hash": "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn",
"size": 4
}
]
```
Now open this hash in `ipfs.io` and try to figure out wtf that is and why size is 4. The `ipfs.types.Buffer` was the key.1 parent 7a931c1 commit e5d90e2
1 file changed
+32
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
184 | 197 | | |
185 | 198 | | |
186 | 199 | | |
187 | 200 | | |
188 | | - | |
| 201 | + | |
189 | 202 | | |
190 | 203 | | |
191 | 204 | | |
192 | | - | |
193 | | - | |
194 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
195 | 223 | | |
196 | 224 | | |
197 | 225 | | |
| |||
0 commit comments