77* [ addFromURL] ( #addfromurl ) TODO: add docs
88* [ bitswap.stat] ( #bitswapstat ) TODO: add docs
99* [ bitswap.wantlist] ( #bitswapwantlist ) TODO: add docs
10- * [ block.get] ( #blockget ) TODO: add docs
10+ * [ block.get] ( #blockget )
11+ * [ block.put] ( #blockput )
12+ * [ block.stat] ( #blockstat )
1113* [ cat] ( #cat )
1214* [ catPullStream] ( #catpullstream ) TODO: add docs
1315* [ ls] ( #ls ) TODO: add docs
@@ -316,6 +318,129 @@ pull(
316318*/
317319```
318320
321+ ## block.get
322+
323+ Fetch a raw block from the IPFS block store or the network via bitswap if not local.
324+
325+ ### ` block.get(cid, [options]): Promise<Buffer> `
326+
327+ #### Parameters
328+
329+ * ` cid ` - CID of the block to fetch
330+ * Type: ` String `
331+ * ` options ` (optional)
332+ * Type: ` Object `
333+ * Default: ` null `
334+ * ` options.signal ` (optional) - A signal that can be used to abort the request
335+ * Type: [ ` AbortSignal ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal )
336+ * Default: ` null `
337+
338+ #### Returns
339+
340+ A buffer containing the raw bytes of the block.
341+
342+ * Type: ` Promise<Buffer> `
343+
344+ #### Example
345+
346+ ``` js
347+ const data = await ipfs .block .get (' zdpuAtpzCB7ma5zNyCN7eh1Vss1dHWuScf91DbE1ix9ZTbjAk' )
348+ console .log (data) // buffer containing block data
349+ ```
350+
351+ ## block.put
352+
353+ Put a block into the IPFS block store.
354+
355+ ### ` block.put(data, [options]): Promise<Object> `
356+
357+ #### Parameters
358+
359+ * ` data ` - Raw data for this block
360+ * Type: ` Buffer ` /` Blob ` /` File `
361+ * ` options ` (optional)
362+ * Type: ` Object `
363+ * Default: ` null `
364+ * ` options.format ` (optional) - Name of the IPLD format this block is encoded with
365+ * Type: ` String `
366+ * Default: ` dag-pb `
367+ * ` options.mhtype ` (optional) - Name of the multihash hashing algorithm to use
368+ * Type: ` String `
369+ * Default: ` sha2-256 `
370+ * ` options.mhlen ` (optional) - Length of the hash in bits
371+ * Type: ` Number `
372+ * Default: ` 256 `
373+ * ` options.pin ` (optional) - Pin this block so it is not garbage collected
374+ * Type: ` Boolean `
375+ * Default: ` false `
376+ * ` options.signal ` (optional) - A signal that can be used to abort the request
377+ * Type: [ ` AbortSignal ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal )
378+ * Default: ` null `
379+
380+ #### Returns
381+
382+ CID and size for the block that was added.
383+
384+ * Type: ` Promise<Object> `
385+
386+ The ` Object ` has the following properties:
387+
388+ * ` key ` - The CID of the block
389+ * Type: ` String `
390+ * ` size ` - Size of the block in bytes
391+ * Type: ` Number `
392+
393+ #### Examples
394+
395+ ``` js
396+ const data = Buffer .from (' blorb' )
397+ const res = await ipfs .block .put (data)
398+ console .log (res)
399+ /*
400+ { key: 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ', size: 5 }
401+ */
402+ ```
403+
404+ ## block.stat
405+
406+ Get status for a block.
407+
408+ ### ` block.stat(cid, [options]): Promise<Object> `
409+
410+ #### Parameters
411+
412+ * ` cid ` - CID of the block
413+ * Type: ` String `
414+ * ` options ` (optional)
415+ * Type: ` Object `
416+ * Default: ` null `
417+ * ` options.signal ` (optional) - A signal that can be used to abort the request
418+ * Type: [ ` AbortSignal ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal )
419+ * Default: ` null `
420+
421+ #### Returns
422+
423+ CID and size of the block.
424+
425+ * Type: ` Promise<Object> `
426+
427+ The ` Object ` has the following properties:
428+
429+ * ` key ` - The CID of the block
430+ * Type: ` String `
431+ * ` size ` - Size of the block in bytes
432+ * Type: ` Number `
433+
434+ #### Examples
435+
436+ ``` js
437+ const res = await ipfs .block .stat (' zb2rhj7crUKTQYRGCRATFaQ6YFLTde2YzdqbbhAASkL9uRDXn' )
438+ console .log (res)
439+ /*
440+ { key: 'zb2rhj7crUKTQYRGCRATFaQ6YFLTde2YzdqbbhAASkL9uRDXn', size: 11 }
441+ */
442+ ```
443+
319444## ` cat `
320445
321446Read files from IPFS.
@@ -335,6 +460,9 @@ Read files from IPFS.
335460* ` options.length ` (optional) - Number of bytes to read
336461 * Type: ` Number `
337462 * Default: ` null ` (read to the end of the file)
463+ * ` options.signal ` (optional) - A signal that can be used to abort the request
464+ * Type: [ ` AbortSignal ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal )
465+ * Default: ` null `
338466
339467#### Returns
340468
0 commit comments