This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Commit 4faa8a9 1 parent ce871a1 commit 4faa8a9 Copy full SHA for 4faa8a9
File tree 5 files changed +45
-11
lines changed
5 files changed +45
-11
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ module.exports = function (config) {
21
21
} ,
22
22
externals : {
23
23
fs : '{}' ,
24
- 'node-forge' : 'forge'
24
+ 'node-forge' : 'forge' ,
25
+ 'ipfs-data-importing' : '{ import: {} }'
25
26
} ,
26
27
node : {
27
28
Buffer : true
Original file line number Diff line number Diff line change 82
82
"hapi" : " ^12.0.0" ,
83
83
"ipfs-api" : " ^2.13.1" ,
84
84
"ipfs-blocks" : " ^0.1.0" ,
85
+ "ipfs-data-importing" : " ^0.3.0" ,
85
86
"ipfs-merkle-dag" : " ^0.2.1" ,
86
87
"ipfs-multipart" : " ^0.1.0" ,
87
88
"ipfs-repo" : " ^0.5.0" ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const Command = require ( 'ronin' ) . Command
4
+ const IPFS = require ( '../../../ipfs-core' )
5
+ const debug = require ( 'debug' )
6
+ const log = debug ( 'cli:version' )
7
+ log . error = debug ( 'cli:version:error' )
8
+ const bs58 = require ( 'bs58' )
9
+
10
+ module . exports = Command . extend ( {
11
+ desc : 'Add a file to IPFS using the UnixFS data format' ,
12
+
13
+ options : {
14
+ recursive : {
15
+ alias : 'r' ,
16
+ type : 'boolean' ,
17
+ default : false
18
+ }
19
+ } ,
20
+
21
+ run : ( recursive , path ) => {
22
+ var node = new IPFS ( )
23
+ path = process . cwd ( ) + '/' + path
24
+ node . files . add ( path , {
25
+ recursive : recursive
26
+ } , ( err , stats ) => {
27
+ if ( err ) {
28
+ return console . log ( err )
29
+ }
30
+ console . log ( 'added' , bs58 . encode ( stats . Hash ) . toString ( ) , stats . Name )
31
+ } )
32
+ }
33
+ } )
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const DAGService = mDAG.DAGService
11
11
const Id = require ( 'peer-id' )
12
12
const Info = require ( 'peer-info' )
13
13
const multiaddr = require ( 'multiaddr' )
14
+ const importer = require ( 'ipfs-data-importing' ) . import
14
15
15
16
exports = module . exports = IPFS
16
17
@@ -320,6 +321,14 @@ function IPFS (repo) {
320
321
records : { } ,
321
322
ping : notImpl
322
323
}
324
+
325
+ this . files = {
326
+ add : ( path , options , callback ) => {
327
+ options . path = path
328
+ options . dagService = dagS
329
+ importer ( options , callback )
330
+ }
331
+ }
323
332
}
324
333
325
334
function notImpl ( ) {
You can’t perform that action at this time.
0 commit comments