diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index d39c637a2e..7a14c675ab 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -650,11 +650,13 @@ App::post('/v1/functions/:functionId/deployments') $end = $request->getContentRangeEnd(); $fileSize = $request->getContentRangeSize(); $deploymentId = $request->getHeader('x-appwrite-id', $deploymentId); - if (is_null($start) || is_null($end) || is_null($fileSize) || $end >= $fileSize) { + // TODO make `end >= $fileSize` in next breaking version + if (is_null($start) || is_null($end) || is_null($fileSize) || $end > $fileSize) { throw new Exception(Exception::STORAGE_INVALID_CONTENT_RANGE); } - if ($end === $fileSize - 1) { + // TODO remove the condition that checks `$end === $fileSize` in next breaking version + if ($end === $fileSize - 1 || $end === $fileSize) { //if it's a last chunks the chunk size might differ, so we set the $chunks and $chunk to notify it's last chunk $chunks = $chunk = -1; } else { diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 47a4656715..d97f8c18ef 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -444,11 +444,13 @@ App::post('/v1/storage/buckets/:bucketId/files') $end = $request->getContentRangeEnd(); $fileSize = $request->getContentRangeSize(); $fileId = $request->getHeader('x-appwrite-id', $fileId); - if (is_null($start) || is_null($end) || is_null($fileSize) || $end >= $fileSize) { + // TODO make `end >= $fileSize` in next breaking version + if (is_null($start) || is_null($end) || is_null($fileSize) || $end > $fileSize) { throw new Exception(Exception::STORAGE_INVALID_CONTENT_RANGE); } - if ($end === $fileSize - 1) { + // TODO remove the condition that checks `$end === $fileSize` in next breaking version + if ($end === $fileSize - 1 || $end === $fileSize) { //if it's a last chunks the chunk size might differ, so we set the $chunks and $chunk to -1 notify it's last chunk $chunks = $chunk = -1; } else {