This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +51
-17
lines changed Expand file tree Collapse file tree 8 files changed +51
-17
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,13 @@ node_js:
33 - " 4"
44 - " 5"
55
6- branches :
7- only :
8- - master
9-
106before_install :
117 - npm i -g npm
128 # Workaround for a permissions issue with Travis virtual machine images
9+
10+ addons :
11+ firefox : ' latest'
12+
1313script :
1414 - npm test
1515
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ module.exports = function (config) {
2121 } ,
2222 externals : {
2323 fs : '{}' ,
24- 'node-forge' : 'forge'
24+ 'node-forge' : 'forge' ,
25+ 'ipfs-data-importing' : '{ import: {} }'
2526 } ,
2627 node : {
2728 Buffer : true
Original file line number Diff line number Diff line change 8282 "hapi" : " ^12.0.0" ,
8383 "ipfs-api" : " ^2.13.1" ,
8484 "ipfs-blocks" : " ^0.1.0" ,
85+ "ipfs-data-importing" : " ^0.3.0" ,
8586 "ipfs-merkle-dag" : " ^0.2.1" ,
8687 "ipfs-multipart" : " ^0.1.0" ,
8788 "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 @@ -140,7 +140,7 @@ exports.replace = {
140140 }
141141
142142 const parser = multipart . reqParser ( request . payload )
143- let file
143+ var file
144144
145145 parser . on ( 'file' , ( fileName , fileStream ) => {
146146 fileStream . on ( 'data' , ( data ) => {
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ exports.put = {
104104 }
105105
106106 const parser = multipart . reqParser ( request . payload )
107- let file
107+ var file
108108
109109 parser . on ( 'file' , ( fileName , fileStream ) => {
110110 fileStream . on ( 'data' , ( data ) => {
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const DAGService = mDAG.DAGService
1111const Id = require ( 'peer-id' )
1212const Info = require ( 'peer-info' )
1313const multiaddr = require ( 'multiaddr' )
14+ const importer = require ( 'ipfs-data-importing' ) . import
1415
1516exports = module . exports = IPFS
1617
@@ -320,6 +321,14 @@ function IPFS (repo) {
320321 records : { } ,
321322 ping : notImpl
322323 }
324+
325+ this . files = {
326+ add : ( path , options , callback ) => {
327+ options . path = path
328+ options . dagService = dagS
329+ importer ( options , callback )
330+ }
331+ }
323332}
324333
325334function notImpl ( ) {
You can’t perform that action at this time.
0 commit comments