1
0
Fork 0
mirror of synced 2024-07-05 22:51:24 +12:00

Merge branch 'feat-large-file' of github.com:lohanidamodar/appwrite into feat-large-file

This commit is contained in:
Damodar Lohani 2021-07-13 13:35:11 +05:45
commit b8e853493f
4 changed files with 12 additions and 10 deletions

View file

@ -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;
return $collections;

View file

@ -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);

View file

@ -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.
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.

View file

@ -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;
}
}
}