This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree 2 files changed +44
-2
lines changed
2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 32
32
"glob-escape" : " 0.0.2" ,
33
33
"ipfs-block" : " ~0.5.5" ,
34
34
"ipfs-unixfs" : " ~0.1.10" ,
35
+ "ipld-dag-cbor" : " ^0.11.1" ,
35
36
"ipld-dag-pb" : " ~0.9.5" ,
36
37
"is-ipfs" : " ~0.3.0" ,
37
38
"isstream" : " ^0.1.2" ,
Original file line number Diff line number Diff line change @@ -66,12 +66,53 @@ module.exports = (send) => {
66
66
if ( err ) {
67
67
return callback ( err )
68
68
}
69
- // TODO handle the result
69
+ if ( result . Cid ) {
70
+ return callback ( null , new CID ( result . Cid [ '/' ] ) )
71
+ } else {
72
+ return callback ( result )
73
+ }
70
74
} )
71
75
}
72
76
} ) ,
73
77
get : promisify ( ( cid , path , options , callback ) => {
74
- // TODO
78
+ if ( typeof path === 'function' ) {
79
+ callback = path
80
+ path = undefined
81
+ }
82
+
83
+ if ( typeof options === 'function' ) {
84
+ callback = options
85
+ options = { }
86
+ }
87
+
88
+ options = options || { }
89
+
90
+ if ( CID . isCID ( cid ) ) {
91
+ cid = cid . toBaseEncodedString ( )
92
+ }
93
+
94
+ if ( typeof cid === 'string' ) {
95
+ const split = cid . split ( '/' )
96
+ cid = split [ 0 ]
97
+ split . shift ( )
98
+
99
+ if ( split . length > 0 ) {
100
+ path = split . join ( '/' )
101
+ } else {
102
+ path = '/'
103
+ }
104
+ }
105
+
106
+ send ( {
107
+ path : 'dag/get' ,
108
+ args : cid + '/' + path ,
109
+ qs : options
110
+ } , ( err , result ) => {
111
+ if ( err ) {
112
+ return callback ( err )
113
+ }
114
+ callback ( undefined , { value : result } )
115
+ } )
75
116
} )
76
117
}
77
118
You can’t perform that action at this time.
0 commit comments