1
0
Fork 0
mirror of synced 2024-07-03 13:41:01 +12:00

fix mock upload

This commit is contained in:
Damodar Lohani 2022-03-04 11:57:44 +05:45 committed by GitHub
parent f193a59da9
commit b3fbb7c40d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -252,7 +252,7 @@ App::post('/v1/mock/tests/general/upload')
$end = $request->getContentRangeEnd();
$size = $request->getContentRangeSize();
$id = $request->getHeader('x-appwrite-id', '');
$file['size'] = (\is_array($file['size'])) ? $file['size'] : [$file['size']];
$file['size'] = (\is_array($file['size'])) ? $file['size'][0] : $file['size'];
if(is_null($start) || is_null($end) || is_null($size)) {
throw new Exception('Invalid content-range header', 400, Exception::GENERAL_MOCK);
@ -274,15 +274,14 @@ App::post('/v1/mock/tests/general/upload')
throw new Exception('Chunk size must be 5MB (except last chunk)', 400, Exception::GENERAL_MOCK);
}
foreach ($file['size'] as $i => $sz) {
if ($end !== $size && $sz !== $chunkSize) {
throw new Exception('Wrong chunk size', 400, Exception::GENERAL_MOCK);
}
if($sz > $chunkSize) {
throw new Exception('Chunk size must be 5MB or less', 400, Exception::GENERAL_MOCK);
}
if ($end !== $size && $file['size'] !== $chunkSize) {
throw new Exception('Wrong chunk size', 400, Exception::GENERAL_MOCK);
}
if($file['size'] > $chunkSize) {
throw new Exception('Chunk size must be 5MB or less', 400, Exception::GENERAL_MOCK);
}
if($end !== $size) {
$response->json([
'$id'=> 'newfileid',