diff --git a/app/config/collections2.php b/app/config/collections2.php index 12d45c0323..92ae0dbcd1 100644 --- a/app/config/collections2.php +++ b/app/config/collections2.php @@ -626,7 +626,7 @@ $collections = [ 'filters' => [], ], [ - '$id' => 'totalChunks', + '$id' => 'chunksTotal', 'type' => Database::VAR_INTEGER, 'format' => '', 'size' => 0, @@ -636,7 +636,7 @@ $collections = [ 'filters' => [], ], [ - '$id' => 'uploadedChunks', + '$id' => 'chunksUploaded', 'type' => Database::VAR_INTEGER, 'format' => '', 'size' => 0, @@ -1152,4 +1152,4 @@ foreach ($auth as $index => $method) { ]; } -return $collections; \ No newline at end of file +return $collections; diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 643c13d030..90620bf7b4 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -317,7 +317,7 @@ App::post('/v1/storage/buckets/:bucketId/files') $chunks = 1; if (!empty($contentRange)) { - $uploadId = empty($request->getHeader('x-appwrite-upload-id')) ? $uploadId : $request->getHeader('x-appwrite-upload-id'); + $uploadId = $request->getHeader('x-appwrite-upload-id', $uploadId); $contentRange = explode(" ", $contentRange); if (count($contentRange) != 2) { throw new Exception('Invalid content-range header', 400); diff --git a/docs/references/storage/create-file.md b/docs/references/storage/create-file.md index e10f418865..729a237d0e 100644 --- a/docs/references/storage/create-file.md +++ b/docs/references/storage/create-file.md @@ -1,5 +1,7 @@ -Create a new file. The user who creates the file will automatically be assigned to read and write access unless he has passed custom values for read and write arguments. +Create a new file. The user who creates the file will automatically be assigned to read and write access unless they have passed custom values for read and write arguments. -Large file should be uploaded using multiple requests using [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send partial request with maximum supported chunk of `2MB`. We assume that the chunk size is the chunk size used in the firs request (may be different for last request.). We assume that in `content-range` header the **range-start**, **range-end** and **size** always sent and unit is always bytes. +Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `2MB`. The `content-range` header values should always be in bytes. -When first request is sent the server sends back the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-upload-id` header for the server to know the partial upload is for existing file not a new file. \ No newline at end of file +When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-upload-id` header to allow the server to know the partial upload is for the existing file and not for a new one. + +If you're creating a new file using one of the Appwrite SDKs, the entire chunking logic will be managed by the SDK internally. diff --git a/src/Appwrite/Utopia/Response/Model/File.php b/src/Appwrite/Utopia/Response/Model/File.php index 50b8f28a99..50f4654ddd 100644 --- a/src/Appwrite/Utopia/Response/Model/File.php +++ b/src/Appwrite/Utopia/Response/Model/File.php @@ -60,13 +60,13 @@ class File extends Model 'default' => 0, 'example' => 17890, ]) - ->addRule('totalChunks', [ + ->addRule('chunksTotal', [ 'type' => self::TYPE_INTEGER, 'description' => 'Total number of chunks available', 'default' => 0, 'example' => 17890, ]) - ->addRule('uploadedChunks', [ + ->addRule('chunksUploaded', [ 'type' => self::TYPE_INTEGER, 'description' => 'Total number of chunks uploaded', 'default' => 0, @@ -94,4 +94,4 @@ class File extends Model { return Response::MODEL_FILE; } -} \ No newline at end of file +}