53
53
- [ Additional Options] ( #additional-options )
54
54
- [ Instance Utils] ( #instance-utils )
55
55
- [ Static Types and Utils] ( #static-types-and-utils )
56
+ - [ Glob source] ( #glob-source )
57
+ - [ URL source] ( #url-source )
56
58
- [ Development] ( #development )
57
59
- [ Testing] ( #testing )
58
60
- [ Contribute] ( #contribute )
@@ -210,34 +212,20 @@ const ipfs = ipfsClient({ timeout: '2m' })
210
212
211
213
- [ Regular Files API] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md )
212
214
- [ ` ipfs.add(data, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#add )
213
- - [ ` ipfs.addPullStream([options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#addpullstream )
214
- - [ ` ipfs.addReadableStream([options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#addreadablestream )
215
- - [ ` ipfs.addFromStream(stream) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#addfromstream )
216
- - [ ` ipfs.addFromFs(path, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#addfromfs )
217
- - [ ` ipfs.addFromURL(url, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#addfromurl )
218
215
- [ ` ipfs.cat(ipfsPath, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#cat )
219
- - [ ` ipfs.catPullStream(ipfsPath, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#catpullstream )
220
- - [ ` ipfs.catReadableStream(ipfsPath, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#catreadablestream )
221
216
- [ ` ipfs.get(ipfsPath, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#get )
222
- - [ ` ipfs.getPullStream(ipfsPath, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#getpullstream )
223
- - [ ` ipfs.getReadableStream(ipfsPath, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#getreadablestream )
224
217
- [ ` ipfs.ls(ipfsPath) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#ls )
225
- - [ ` ipfs.lsPullStream(ipfsPath) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#lspullstream )
226
- - [ ` ipfs.lsReadableStream(ipfsPath) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#lsreadablestream )
227
218
- [ MFS (mutable file system) specific] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#mutable-file-system )
228
-
229
- _ Explore the Mutable File System through interactive coding challenges in our [ ProtoSchool tutorial] ( https://proto.school/#/mutable-file-system/ ) ._
230
219
- [ ` ipfs.files.cp([from, to]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filescp )
231
220
- [ ` ipfs.files.flush([path]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesflush )
232
221
- [ ` ipfs.files.ls([path], [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesls )
233
222
- [ ` ipfs.files.mkdir(path, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesmkdir )
234
223
- [ ` ipfs.files.mv([from, to]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesmv )
235
224
- [ ` ipfs.files.read(path, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesread )
236
- - [ ` ipfs.files.readPullStream(path, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesreadpullstream )
237
- - [ ` ipfs.files.readReadableStream(path, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesreadreadablestream )
238
225
- [ ` ipfs.files.rm(path, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesrm )
239
226
- [ ` ipfs.files.stat(path, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesstat )
240
227
- [ ` ipfs.files.write(path, content, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#fileswrite )
228
+ _ Explore the Mutable File System through interactive coding challenges in our [ ProtoSchool tutorial] ( https://proto.school/#/mutable-file-system/ ) ._
241
229
242
230
- [ block] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md )
243
231
- [ ` ipfs.block.get(cid, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md#blockget )
@@ -246,20 +234,15 @@ const ipfs = ipfsClient({ timeout: '2m' })
246
234
247
235
- [ refs] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REFS.md )
248
236
- [ ` ipfs.refs(ipfsPath, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REFS.md#refs )
249
- - [ ` ipfs.refsReadableStream(ipfsPath, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REFS.md#refsreadablestream )
250
- - [ ` ipfs.refsPullStream(ipfsPath, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REFS.md#refspullstream )
251
237
- [ ` ipfs.refs.local() ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REFS.md#refslocal )
252
- - [ ` ipfs.refs.localReadableStream() ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REFS.md#refslocalreadablestream )
253
- - [ ` ipfs.refs.localPullStream() ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REFS.md#refslocalpullstream )
254
238
255
239
#### Graph
256
240
257
241
- [ dag] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md )
258
-
259
- _ Explore the DAG API through interactive coding challenges in our [ ProtoSchool tutorial] ( https://proto.school/#/basics ) ._
260
242
- [ ` ipfs.dag.get(cid, [path], [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagget )
261
243
- [ ` ipfs.dag.put(dagNode, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput )
262
244
- [ ` ipfs.dag.tree(cid, [path], [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagtree )
245
+ _ Explore the DAG API through interactive coding challenges in our [ ProtoSchool tutorial] ( https://proto.school/#/basics ) ._
263
246
264
247
- [ object] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md )
265
248
- [ ` ipfs.object.data(multihash, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectdata )
@@ -278,9 +261,6 @@ const ipfs = ipfsClient({ timeout: '2m' })
278
261
- [ ` ipfs.pin.ls([hash], [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md#pinls )
279
262
- [ ` ipfs.pin.rm(hash, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md#pinrm )
280
263
281
- - refs
282
- - ` ipfs.refs.local() `
283
-
284
264
#### Network
285
265
286
266
- [ bootstrap] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md )
@@ -326,8 +306,6 @@ const ipfs = ipfsClient({ timeout: '2m' })
326
306
- [ ` ipfs.dns(domain) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#dns )
327
307
- [ ` ipfs.id() ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#id )
328
308
- [ ` ipfs.ping(id, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#ping )
329
- - [ ` ipfs.pingPullStream(id, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#pingpullstream )
330
- - [ ` ipfs.pingReadableStream(id, [options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#pingreadablestream )
331
309
- [ ` ipfs.stop() ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#stop ) . Alias to ` ipfs.shutdown ` .
332
310
- [ ` ipfs.version() ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#version )
333
311
@@ -341,8 +319,6 @@ const ipfs = ipfsClient({ timeout: '2m' })
341
319
- [ stats] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md )
342
320
- [ ` ipfs.stats.bitswap() ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsbitswap )
343
321
- [ ` ipfs.stats.bw([options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsbw )
344
- - [ ` ipfs.stats.bwPullStream([options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsbwpullstream )
345
- - [ ` ipfs.stats.bwReadableStream([options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsbwreadablestream )
346
322
- [ ` ipfs.stats.repo([options]) ` ] ( https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsrepo )
347
323
348
324
- log
@@ -382,15 +358,14 @@ Call this on your client instance to return an object containing the `host`, `po
382
358
383
359
Aside from the default export, ` ipfs-http-client ` exports various types and utilities that are included in the bundle:
384
360
385
- - [ ` isIPFS ` ] ( https://www.npmjs.com/package/is-ipfs )
386
361
- [ ` Buffer ` ] ( https://www.npmjs.com/package/buffer )
387
- - [ ` PeerId ` ] ( https://www.npmjs.com/package/peer-id )
388
- - [ ` PeerInfo ` ] ( https://www.npmjs.com/package/peer-info )
389
362
- [ ` multiaddr ` ] ( https://www.npmjs.com/package/multiaddr )
390
363
- [ ` multibase ` ] ( https://www.npmjs.com/package/multibase )
391
364
- [ ` multicodec ` ] ( https://www.npmjs.com/package/multicodec )
392
- - [ ` multihash ` ] ( https://www.npmjs.com/package/multihash )
365
+ - [ ` multihash ` ] ( https://www.npmjs.com/package/multihashes )
393
366
- [ ` CID ` ] ( https://www.npmjs.com/package/cids )
367
+ - [ ` globSource ` ] ( https://github.com/ipfs/js-ipfs-utils/blob/master/src/files/glob-source.js ) (not available in the browser)
368
+ - [ ` urlSource ` ] ( https://github.com/ipfs/js-ipfs-utils/blob/master/src/files/url-source.js )
394
369
395
370
These can be accessed like this, for example:
396
371
@@ -400,6 +375,74 @@ const { CID } = require('ipfs-http-client')
400
375
import { CID } from ' ipfs-http-client'
401
376
```
402
377
378
+ ##### Glob source
379
+
380
+ A utility to allow files on the file system to be easily added to IPFS.
381
+
382
+ ###### ` globSource(path, [options]) `
383
+
384
+ - ` path ` : A path to a single file or directory to glob from
385
+ - ` options ` : Optional options
386
+ - ` options.recursive ` : If ` path ` is a directory, use option ` { recursive: true } ` to add the directory and all its sub-directories.
387
+ - ` options.ignore ` : To exclude file globs from the directory, use option ` { ignore: ['ignore/this/folder/**', 'and/this/file'] } ` .
388
+ - ` options.hidden ` : Hidden/dot files (files or folders starting with a ` . ` , for example, ` .git/ ` ) are not included by default. To add them, use the option ` { hidden: true } ` .
389
+
390
+ Returns an async iterable that yields ` { path, content } ` objects suitable for passing to ` ipfs.add ` .
391
+
392
+ ###### Example
393
+
394
+ ``` js
395
+ const IpfsHttpClient = require (' ipfs-http-client' )
396
+ const { globSource } = IpfsHttpClient
397
+ const ipfs = IpfsHttpClient ()
398
+
399
+ for await (const file of ipfs .add (globSource (' ./docs' , { recursive: true }))) {
400
+ console .log (file)
401
+ }
402
+ /*
403
+ {
404
+ path: 'docs/assets/anchor.js',
405
+ hash: 'QmVHxRocoWgUChLEvfEyDuuD6qJ4PhdDL2dTLcpUy3dSC2',
406
+ size: 15347
407
+ }
408
+ {
409
+ path: 'docs/assets/bass-addons.css',
410
+ hash: 'QmPiLWKd6yseMWDTgHegb8T7wVS7zWGYgyvfj7dGNt2viQ',
411
+ size: 232
412
+ }
413
+ ...
414
+ */
415
+ ```
416
+
417
+ ##### URL source
418
+
419
+ A utility to allow content from the internet to be easily added to IPFS.
420
+
421
+ ###### ` urlSource(url) `
422
+
423
+ - ` url ` : A string URL or [ ` URL ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/URL ) instance to send HTTP GET request to
424
+
425
+ Returns an async iterable that yields ` { path, content } ` objects suitable for passing to ` ipfs.add ` .
426
+
427
+ ###### Example
428
+
429
+ ``` js
430
+ const IpfsHttpClient = require (' ipfs-http-client' )
431
+ const { urlSource } = IpfsHttpClient
432
+ const ipfs = IpfsHttpClient ()
433
+
434
+ for await (const file of ipfs .add (urlSource (' https://ipfs.io/images/ipfs-logo.svg' ))) {
435
+ console .log (file)
436
+ }
437
+ /*
438
+ {
439
+ path: 'ipfs-logo.svg',
440
+ hash: 'QmTqZhR6f7jzdhLgPArDPnsbZpvvgxzCZycXK7ywkLxSyU',
441
+ size: 3243
442
+ }
443
+ */
444
+ ```
445
+
403
446
## Development
404
447
405
448
### Testing
0 commit comments