This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,8 @@ exports.add = {
161
161
'only-hash' : Joi . boolean ( ) ,
162
162
pin : Joi . boolean ( ) . default ( true ) ,
163
163
'wrap-with-directory' : Joi . boolean ( ) ,
164
- chunker : Joi . string ( )
164
+ chunker : Joi . string ( ) ,
165
+ trickle : Joi . boolean ( )
165
166
} )
166
167
// TODO: Necessary until validate "recursive", "stream-channels" etc.
167
168
. options ( { allowUnknown : true } )
@@ -218,7 +219,8 @@ exports.add = {
218
219
hashAlg : request . query . hash ,
219
220
wrapWithDirectory : request . query [ 'wrap-with-directory' ] ,
220
221
pin : request . query . pin ,
221
- chunker : request . query . chunker
222
+ chunker : request . query . chunker ,
223
+ strategy : request . query . trickle ? 'trickle' : 'balanced'
222
224
}
223
225
224
226
const aborter = abortable ( )
Original file line number Diff line number Diff line change @@ -76,6 +76,40 @@ module.exports = (http) => {
76
76
expect ( res . statusCode ) . to . equal ( 200 )
77
77
expect ( multibase . isEncoded ( JSON . parse ( res . result ) . Hash ) ) . to . deep . equal ( 'base64' )
78
78
} )
79
+
80
+ it ( 'should add data using the trickle importer' , async ( ) => {
81
+ const form = new FormData ( )
82
+ form . append ( 'data' , Buffer . from ( 'TEST\n' ) )
83
+ const headers = form . getHeaders ( )
84
+
85
+ const payload = await streamToPromise ( form )
86
+ const res = await api . inject ( {
87
+ method : 'POST' ,
88
+ url : '/api/v0/add?trickle=true&pin=false' ,
89
+ headers,
90
+ payload
91
+ } )
92
+
93
+ expect ( res . statusCode ) . to . equal ( 200 )
94
+ expect ( JSON . parse ( res . result ) . Hash ) . to . equal ( 'QmRJTAvvv1UNgCXxK9grf6u2pCT2ZQ2wCwsojpC1sTjkp9' )
95
+ } )
96
+
97
+ it ( 'should add data using the balanced importer' , async ( ) => {
98
+ const form = new FormData ( )
99
+ form . append ( 'data' , Buffer . from ( 'TEST\n' ) )
100
+ const headers = form . getHeaders ( )
101
+
102
+ const payload = await streamToPromise ( form )
103
+ const res = await api . inject ( {
104
+ method : 'POST' ,
105
+ url : '/api/v0/add?pin=false' ,
106
+ headers,
107
+ payload
108
+ } )
109
+
110
+ expect ( res . statusCode ) . to . equal ( 200 )
111
+ expect ( JSON . parse ( res . result ) . Hash ) . to . equal ( 'Qmdudp5XvJr7KrqK6fQ7m2ACStoRxuwfovNHnY6dAAeUis' )
112
+ } )
79
113
} )
80
114
81
115
describe ( '/cat' , ( ) => {
You can’t perform that action at this time.
0 commit comments