This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +12
-10
lines changed Expand file tree Collapse file tree 6 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,9 @@ module.exports = Command.extend({
35
35
if ( err ) {
36
36
throw ( err )
37
37
}
38
+ console . log ( res )
38
39
if ( res ) {
39
- res . on ( 'file ' , ( data ) => {
40
+ res . on ( 'data ' , ( data ) => {
40
41
data . stream . pipe ( process . stdout )
41
42
} )
42
43
}
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ module.exports = Command.extend({
84
84
if ( err ) {
85
85
throw err
86
86
}
87
- result . on ( 'file ' , fileHandler ( result , dir ) )
87
+ result . on ( 'data ' , fileHandler ( result , dir ) )
88
88
} )
89
89
} )
90
90
}
Original file line number Diff line number Diff line change @@ -44,8 +44,8 @@ module.exports = function files (self) {
44
44
if ( data . type === 'directory' ) {
45
45
callback ( 'This dag node is a directory' , null )
46
46
} else {
47
- const exportEvent = Exporter ( hash , self . _dagS )
48
- callback ( null , exportEvent )
47
+ const exportStream = Exporter ( hash , self . _dagS )
48
+ callback ( null , exportStream )
49
49
}
50
50
} )
51
51
} ,
Original file line number Diff line number Diff line change @@ -34,15 +34,15 @@ exports.cat = {
34
34
handler : ( request , reply ) => {
35
35
const key = request . pre . args . key
36
36
37
- request . server . app . ipfs . files . cat ( key , ( err , ee ) => {
37
+ request . server . app . ipfs . files . cat ( key , ( err , stream ) => {
38
38
if ( err ) {
39
39
log . error ( err )
40
40
return reply ( {
41
41
Message : 'Failed to cat file: ' + err ,
42
42
Code : 0
43
43
} ) . code ( 500 )
44
44
}
45
- ee . on ( 'file ' , ( data ) => {
45
+ stream . on ( 'data ' , ( data ) => {
46
46
return reply ( data . stream )
47
47
} )
48
48
} )
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ describe('files', () => {
37
37
const hash = 'QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o'
38
38
ipfs . files . cat ( hash , ( err , res ) => {
39
39
expect ( err ) . to . not . exist
40
- res . on ( 'file ' , ( data ) => {
40
+ res . on ( 'data ' , ( data ) => {
41
41
data . stream . pipe ( bl ( ( err , bldata ) => {
42
42
expect ( err ) . to . not . exist
43
43
expect ( bldata . toString ( ) ) . to . equal ( 'hello world\n' )
@@ -52,7 +52,7 @@ describe('files', () => {
52
52
const hash = 'QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o'
53
53
ipfs . files . get ( hash , ( err , res ) => {
54
54
expect ( err ) . to . not . exist
55
- res . on ( 'file ' , ( data ) => {
55
+ res . on ( 'data ' , ( data ) => {
56
56
data . stream . pipe ( bl ( ( err , bldata ) => {
57
57
expect ( err ) . to . not . exist
58
58
expect ( bldata . toString ( ) ) . to . equal ( 'hello world\n' )
Original file line number Diff line number Diff line change @@ -36,12 +36,13 @@ module.exports = (httpAPI) => {
36
36
} )
37
37
} )
38
38
39
- it ( 'returns a stream ' , ( done ) => {
39
+ it ( 'returns a buffer ' , ( done ) => {
40
40
api . inject ( {
41
41
method : 'GET' ,
42
42
url : '/api/v0/cat?arg=QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o'
43
43
} , ( res ) => {
44
44
expect ( res . statusCode ) . to . equal ( 200 )
45
+ expect ( res . rawPayload ) . to . deep . equal ( new Buffer ( 'hello world' + '\n' ) )
45
46
expect ( res . payload ) . to . equal ( 'hello world' + '\n' )
46
47
done ( )
47
48
} )
@@ -72,7 +73,7 @@ module.exports = (httpAPI) => {
72
73
} )
73
74
} )
74
75
75
- it ( 'returns a stream ' , ( done ) => {
76
+ it ( 'returns a buffer ' , ( done ) => {
76
77
ctl . cat ( 'QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o' , ( err , result ) => {
77
78
expect ( err ) . to . not . exist
78
79
expect ( result ) . to . deep . equal ( new Buffer ( 'hello world' + '\n' ) )
You can’t perform that action at this time.
0 commit comments