@@ -147,7 +147,7 @@ describe("File upload", function () {
147147 imagekit . upload ( fileOptions , callback ) ;
148148 } ) ;
149149
150- it ( 'Buffer file' , function ( done ) {
150+ it ( 'Buffer file smaller than 10MB ' , function ( done ) {
151151 const fileOptions = {
152152 fileName : "test_file_name" ,
153153 file : fs . readFileSync ( path . join ( __dirname , "./data/test_image.jpg" ) )
@@ -165,6 +165,27 @@ describe("File upload", function () {
165165
166166 imagekit . upload ( fileOptions ) ;
167167 } ) ;
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+ } ) ;
168189
169190 it ( 'Missing useUniqueFileName' , function ( done ) {
170191 const fileOptions = {
@@ -352,4 +373,4 @@ describe("File upload", function () {
352373 done ( ) ;
353374 } )
354375 } ) ;
355- } ) ;
376+ } ) ;
0 commit comments