This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 5 files changed +17
-12
lines changed
5 files changed +17
-12
lines changed Original file line number Diff line number Diff line change 45
45
"form-data" : " ^1.0.0-rc3" ,
46
46
"gulp" : " ^3.9.1" ,
47
47
"idb-plus-blob-store" : " ^1.1.2" ,
48
- "interface-ipfs-core" : " ^0.2.2 " ,
48
+ "interface-ipfs-core" : " ^0.3.0 " ,
49
49
"left-pad" : " ^1.1.0" ,
50
50
"lodash" : " ^4.11.2" ,
51
51
"mocha" : " ^2.5.1" ,
67
67
"glob" : " ^7.0.3" ,
68
68
"hapi" : " ^13.4.1" ,
69
69
"ipfs-bitswap" : " ^0.4.1" ,
70
- "ipfs-api" : " ^5 .0.1" ,
70
+ "ipfs-api" : " ^6 .0.1" ,
71
71
"ipfs-block" : " ^0.3.0" ,
72
72
"ipfs-block-service" : " ^0.4.0" ,
73
73
"ipfs-merkle-dag" : " ^0.6.0" ,
Original file line number Diff line number Diff line change @@ -31,13 +31,11 @@ module.exports = Command.extend({
31
31
} )
32
32
return
33
33
}
34
- ipfs . files . cat ( path , ( err , res ) => {
34
+ ipfs . files . cat ( path , ( err , file ) => {
35
35
if ( err ) {
36
36
throw ( err )
37
37
}
38
- res . on ( 'data' , ( data ) => {
39
- data . content . pipe ( process . stdout )
40
- } )
38
+ file . pipe ( process . stdout )
41
39
} )
42
40
} )
43
41
}
Original file line number Diff line number Diff line change @@ -57,5 +57,6 @@ function IPFS (repoInstance) {
57
57
this . object = object ( this )
58
58
this . libp2p = libp2p ( this )
59
59
this . files = files ( this )
60
+ this . cat = files ( this ) . cat // Alias for js-ipfs-api cat
60
61
this . bitswap = bitswap ( this )
61
62
}
Original file line number Diff line number Diff line change @@ -100,20 +100,26 @@ module.exports = function files (self) {
100
100
i . end ( )
101
101
} ) ,
102
102
103
- cat : ( hash , callback ) => {
103
+ cat : promisify ( ( hash , callback ) => {
104
+ if ( typeof hash === 'function' ) {
105
+ return callback ( new Error ( 'You must supply a multihash' ) )
106
+ }
104
107
self . _dagS . get ( hash , ( err , fetchedNode ) => {
105
108
if ( err ) {
106
- return callback ( err , null )
109
+ return callback ( err )
107
110
}
108
111
const data = UnixFS . unmarshal ( fetchedNode . data )
109
112
if ( data . type === 'directory' ) {
110
- callback ( 'This dag node is a directory' , null )
113
+ callback ( new Error ( 'This dag node is a directory' ) )
111
114
} else {
112
115
const exportStream = Exporter ( hash , self . _dagS )
113
- callback ( null , exportStream )
116
+ exportStream . once ( 'data' , ( object ) => {
117
+ callback ( null , object . content )
118
+ } )
114
119
}
115
120
} )
116
- } ,
121
+ } ) ,
122
+
117
123
get : ( hash , callback ) => {
118
124
var exportFile = Exporter ( hash , self . _dagS )
119
125
callback ( null , exportFile )
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ exports.cat = {
43
43
} ) . code ( 500 )
44
44
}
45
45
stream . on ( 'data' , ( data ) => {
46
- return reply ( data . content )
46
+ return reply ( data )
47
47
} )
48
48
} )
49
49
}
You can’t perform that action at this time.
0 commit comments