@@ -244,9 +244,9 @@ public function updateBucket(string $bucketId, string $name, string $permission,
244244 *
245245 * @param string $bucketId
246246 * @throws AppwriteException
247- * @return string
247+ * @return array
248248 */
249- public function deleteBucket (string $ bucketId ): string
249+ public function deleteBucket (string $ bucketId ): array
250250 {
251251 if (!isset ($ bucketId )) {
252252 throw new AppwriteException ('Missing required parameter: "bucketId" ' );
@@ -387,36 +387,47 @@ public function createFile(string $bucketId, string $fileId, string $file, array
387387 return $ this ->client ->call (Client::METHOD_POST , $ path , [
388388 'content-type ' => 'multipart/form-data ' ,
389389 ], $ params );
390- } else {
391- $ id = '' ;
392- $ handle = @fopen ($ file , "rb " );
393- $ counter = 0 ;
394- $ headers = ['content-type ' => 'multipart/form-data ' ];
395- while (!feof ($ handle )) {
396- $ params ['file ' ] = new \CURLFile ('data:// ' . $ mimeType . ';base64, ' . base64_encode (@fread ($ handle , Client::CHUNK_SIZE )), $ mimeType , $ postedName );
397- $ headers ['content-range ' ] = 'bytes ' . ($ counter * Client::CHUNK_SIZE ) . '- ' . min (((($ counter * Client::CHUNK_SIZE ) + Client::CHUNK_SIZE ) - 1 ), $ size ) . '/ ' . $ size ;
398- if (!empty ($ id )) {
399- $ headers ['x-appwrite-id ' ] = $ id ;
400- }
401- $ response = $ this ->client ->call (Client::METHOD_POST , $ path , $ headers , $ params );
402- $ counter ++;
403- if (empty ($ id )) {
404- $ id = $ response ['$id ' ];
405- }
406- if ($ onProgress !== null ) {
407- $ end = min (((($ counter * Client::CHUNK_SIZE ) + Client::CHUNK_SIZE ) - 1 ), $ size );
408- $ onProgress ([
409- '$id ' => $ response ['$id ' ],
410- 'progress ' => min (($ counter +1 ) * Client::CHUNK_SIZE , $ size ) / $ size * 100 ,
411- 'sizeUploaded ' => $ end + 1 ,
412- 'chunksTotal ' => $ response ['chunksTotal ' ],
413- 'chunksUploaded ' => $ response ['chunksUploaded ' ]
414- ]);
390+ }
391+
392+ $ id = '' ;
393+ $ counter = 0 ;
394+
395+ if ($ fileId != 'unique() ' ) {
396+ try {
397+ $ response = $ this ->client ->call (Client::METHOD_GET , new URL ($ path . '/ ' . fileId), headers);
398+ $ counter = $ response ['chunksUploaded ' ] ?? 0 ;
399+ } catch (\Exception $ e ) {
415400 }
416401 }
417- @fclose ($ handle );
418- return $ response ;
402+
403+ $ headers = ['content-type ' => 'multipart/form-data ' ];
404+ $ handle = @fopen ($ file , "rb " );
405+ $ start = $ counter * Client::CHUNK_SIZE ;
406+ while ($ start < $ size ) {
407+ fseek ($ handle , $ start );
408+ $ params ['file ' ] = new \CURLFile ('data:// ' . $ mimeType . ';base64, ' . base64_encode (@fread ($ handle , Client::CHUNK_SIZE )), $ mimeType , $ postedName );
409+ $ headers ['content-range ' ] = 'bytes ' . ($ counter * Client::CHUNK_SIZE ) . '- ' . min (((($ counter * Client::CHUNK_SIZE ) + Client::CHUNK_SIZE ) - 1 ), $ size ) . '/ ' . $ size ;
410+ if (!empty ($ id )) {
411+ $ headers ['x-appwrite-id ' ] = $ id ;
412+ }
413+ $ response = $ this ->client ->call (Client::METHOD_POST , $ path , $ headers , $ params );
414+ $ counter ++;
415+ $ start += Client::CHUNK_SIZE ;
416+ if (empty ($ id )) {
417+ $ id = $ response ['$id ' ];
418+ }
419+ if ($ onProgress !== null ) {
420+ $ onProgress ([
421+ '$id ' => $ response ['$id ' ],
422+ 'progress ' => min (((($ counter * Client::CHUNK_SIZE ) + Client::CHUNK_SIZE ) - 1 ), $ size ) / $ size * 100 ,
423+ 'sizeUploaded ' => min ($ counter * Client::CHUNK_SIZE ),
424+ 'chunksTotal ' => $ response ['chunksTotal ' ],
425+ 'chunksUploaded ' => $ response ['chunksUploaded ' ],
426+ ]);
427+ }
419428 }
429+ @fclose ($ handle );
430+ return $ response ;
420431 }
421432
422433 /**
@@ -496,9 +507,9 @@ public function updateFile(string $bucketId, string $fileId, array $read = null,
496507 * @param string $bucketId
497508 * @param string $fileId
498509 * @throws AppwriteException
499- * @return string
510+ * @return array
500511 */
501- public function deleteFile (string $ bucketId , string $ fileId ): string
512+ public function deleteFile (string $ bucketId , string $ fileId ): array
502513 {
503514 if (!isset ($ bucketId )) {
504515 throw new AppwriteException ('Missing required parameter: "bucketId" ' );
0 commit comments