@@ -147,7 +147,7 @@ describe("File upload", function () {
147
147
imagekit . upload ( fileOptions , callback ) ;
148
148
} ) ;
149
149
150
- it ( 'Buffer file' , function ( done ) {
150
+ it ( 'Buffer file smaller than 10MB ' , function ( done ) {
151
151
const fileOptions = {
152
152
fileName : "test_file_name" ,
153
153
file : fs . readFileSync ( path . join ( __dirname , "./data/test_image.jpg" ) )
@@ -165,6 +165,27 @@ describe("File upload", function () {
165
165
166
166
imagekit . upload ( fileOptions ) ;
167
167
} ) ;
168
+
169
+ it ( 'Buffer file larger than 10MB' , function ( done ) {
170
+ const fileOptions = {
171
+ fileName : "test_file_name" ,
172
+ file : Buffer . alloc ( 15000000 ) , // static buffer of 15 MB size
173
+ } ;
174
+
175
+ const scope = nock ( 'https://upload.imagekit.io/api' )
176
+ . post ( '/v1/files/upload' )
177
+ . basicAuth ( { user : initializationParams . privateKey , pass : '' } )
178
+ . reply ( 200 , function ( uri , requestBody ) {
179
+ expect ( this . req . headers [ "content-type" ] ) . include ( "multipart/form-data; boundary=---------------------" ) ;
180
+ var boundary = this . req . headers [ "content-type" ] . replace ( "multipart/form-data; boundary=" , "" ) ;
181
+ expect ( requestBody . length ) . equal ( 15000347 ) ;
182
+ } )
183
+
184
+ imagekit . upload ( fileOptions , function ( err , result ) {
185
+ expect ( err ) . to . equal ( null )
186
+ done ( ) ;
187
+ } ) ;
188
+ } ) ;
168
189
169
190
it ( 'Missing useUniqueFileName' , function ( done ) {
170
191
const fileOptions = {
@@ -352,4 +373,4 @@ describe("File upload", function () {
352
373
done ( ) ;
353
374
} )
354
375
} ) ;
355
- } ) ;
376
+ } ) ;
0 commit comments