@@ -132,7 +132,7 @@ class Functions extends Service {
132
132
/**
133
133
* List the currently active function runtimes.
134
134
*
135
- * Get a list of all runtimes that are currently active in your project .
135
+ * Get a list of all runtimes that are currently active on your instance .
136
136
*
137
137
* @throws {AppwriteException }
138
138
* @returns {Promise }
@@ -359,53 +359,57 @@ class Functions extends Service {
359
359
const { size : size } = await promisify ( fs . stat ) ( code ) ;
360
360
361
361
if ( size <= client . CHUNK_SIZE ) {
362
- payload [ 'code' ] = fs . createReadStream ( code ) ;
362
+ payload [ 'code' ] = fs . createReadStream ( code ) ;
363
363
364
- return await this . client . call ( 'post' , path , {
364
+ return await this . client . call ( 'post' , path , {
365
365
'content-type' : 'multipart/form-data' ,
366
- } , payload ) ;
366
+ } , payload ) ;
367
367
} else {
368
- let id = undefined ;
369
- let response = undefined ;
370
-
371
- const totalCounters = Math . ceil ( size / client . CHUNK_SIZE ) ;
372
-
373
- for ( let counter = 0 ; counter < totalCounters ; counter ++ ) {
374
- const start = ( counter * client . CHUNK_SIZE ) ;
375
- const end = Math . min ( ( ( ( counter * client . CHUNK_SIZE ) + client . CHUNK_SIZE ) - 1 ) , size ) ;
376
- const headers = {
377
- 'content-type' : 'multipart/form-data' ,
378
- 'content-range' : 'bytes ' + start + '-' + end + '/' + size
379
- } ;
380
-
381
- if ( id ) {
382
- headers [ 'x-appwrite-id' ] = id ;
383
- }
384
-
385
- const stream = fs . createReadStream ( code , {
386
- start,
387
- end
388
- } ) ;
389
- payload [ 'code' ] = stream ;
390
-
391
- response = await this . client . call ( 'post' , path , headers , payload ) ;
392
-
393
- if ( ! id ) {
394
- id = response [ '$id' ] ;
395
- }
396
-
397
- if ( onProgress !== null ) {
398
- onProgress ( {
399
- $id : response [ '$id' ] ,
400
- progress : Math . min ( ( counter + 1 ) * client . CHUNK_SIZE , size ) / size * 100 ,
401
- sizeUploaded : end + 1 ,
402
- chunksTotal : response [ 'chunksTotal' ] ,
403
- chunksUploaded : response [ 'chunksUploaded' ]
404
- } ) ;
405
- }
368
+ let id = undefined ;
369
+ let response = undefined ;
370
+
371
+ let counter = 0 ;
372
+ const totalCounters = Math . ceil ( size / client . CHUNK_SIZE ) ;
373
+
374
+ const headers = {
375
+ 'content-type' : 'multipart/form-data' ,
376
+ } ;
377
+
378
+
379
+ for ( counter ; counter < totalCounters ; counter ++ ) {
380
+ const start = ( counter * client . CHUNK_SIZE ) ;
381
+ const end = Math . min ( ( ( ( counter * client . CHUNK_SIZE ) + client . CHUNK_SIZE ) - 1 ) , size ) ;
382
+
383
+ headers [ 'content-range' ] = 'bytes ' + start + '-' + end + '/' + size ;
384
+
385
+ if ( id ) {
386
+ headers [ 'x-appwrite-id' ] = id ;
387
+ }
388
+
389
+ const stream = fs . createReadStream ( code , {
390
+ start,
391
+ end
392
+ } ) ;
393
+ payload [ 'code' ] = stream ;
394
+
395
+ response = await this . client . call ( 'post' , path , headers , payload ) ;
396
+
397
+ if ( ! id ) {
398
+ id = response [ '$id' ] ;
399
+ }
400
+
401
+ if ( onProgress !== null ) {
402
+ onProgress ( {
403
+ $id : response [ '$id' ] ,
404
+ progress : Math . min ( ( counter + 1 ) * client . CHUNK_SIZE , size ) / size * 100 ,
405
+ sizeUploaded : end + 1 ,
406
+ chunksTotal : response [ 'chunksTotal' ] ,
407
+ chunksUploaded : response [ 'chunksUploaded' ]
408
+ } ) ;
406
409
}
410
+ }
407
411
408
- return response ;
412
+ return response ;
409
413
}
410
414
}
411
415
0 commit comments