mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge branch 'master' of https://github.com/appwrite/appwrite into chore-prepare-0-13-1
This commit is contained in:
commit
2fd6dc9fa1
11 changed files with 62 additions and 60 deletions
|
|
@ -63,7 +63,7 @@ return [
|
||||||
[
|
[
|
||||||
'key' => 'flutter',
|
'key' => 'flutter',
|
||||||
'name' => 'Flutter',
|
'name' => 'Flutter',
|
||||||
'version' => '4.0.0',
|
'version' => '4.0.1',
|
||||||
'url' => 'https://github.com/appwrite/sdk-for-flutter',
|
'url' => 'https://github.com/appwrite/sdk-for-flutter',
|
||||||
'package' => 'https://pub.dev/packages/appwrite',
|
'package' => 'https://pub.dev/packages/appwrite',
|
||||||
'enabled' => true,
|
'enabled' => true,
|
||||||
|
|
@ -352,7 +352,7 @@ return [
|
||||||
[
|
[
|
||||||
'key' => 'dart',
|
'key' => 'dart',
|
||||||
'name' => 'Dart',
|
'name' => 'Dart',
|
||||||
'version' => '4.0.0',
|
'version' => '4.0.1',
|
||||||
'url' => 'https://github.com/appwrite/sdk-for-dart',
|
'url' => 'https://github.com/appwrite/sdk-for-dart',
|
||||||
'package' => 'https://pub.dev/packages/dart_appwrite',
|
'package' => 'https://pub.dev/packages/dart_appwrite',
|
||||||
'enabled' => true,
|
'enabled' => true,
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ App::post('/v1/mock/tests/general/upload')
|
||||||
$end = $request->getContentRangeEnd();
|
$end = $request->getContentRangeEnd();
|
||||||
$size = $request->getContentRangeSize();
|
$size = $request->getContentRangeSize();
|
||||||
$id = $request->getHeader('x-appwrite-id', '');
|
$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)) {
|
if(is_null($start) || is_null($end) || is_null($size)) {
|
||||||
throw new Exception('Invalid content-range header', 400, Exception::GENERAL_MOCK);
|
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);
|
throw new Exception('Chunk size must be 5MB (except last chunk)', 400, Exception::GENERAL_MOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($file['size'] as $i => $sz) {
|
if ($end !== $size && $file['size'] !== $chunkSize) {
|
||||||
if ($end !== $size && $sz !== $chunkSize) {
|
throw new Exception('Wrong chunk size', 400, Exception::GENERAL_MOCK);
|
||||||
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($file['size'] > $chunkSize) {
|
||||||
|
throw new Exception('Chunk size must be 5MB or less', 400, Exception::GENERAL_MOCK);
|
||||||
|
}
|
||||||
|
|
||||||
if($end !== $size) {
|
if($end !== $size) {
|
||||||
$response->json([
|
$response->json([
|
||||||
'$id'=> 'newfileid',
|
'$id'=> 'newfileid',
|
||||||
|
|
@ -291,26 +290,20 @@ App::post('/v1/mock/tests/general/upload')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$file['tmp_name'] = (\is_array($file['tmp_name'])) ? $file['tmp_name'] : [$file['tmp_name']];
|
$file['tmp_name'] = (\is_array($file['tmp_name'])) ? $file['tmp_name'][0] : $file['tmp_name'];
|
||||||
$file['name'] = (\is_array($file['name'])) ? $file['name'] : [$file['name']];
|
$file['name'] = (\is_array($file['name'])) ? $file['name'][0] : $file['name'];
|
||||||
$file['size'] = (\is_array($file['size'])) ? $file['size'] : [$file['size']];
|
$file['size'] = (\is_array($file['size'])) ? $file['size'][0] : $file['size'];
|
||||||
|
|
||||||
foreach ($file['name'] as $i => $name) {
|
if ($file['name'] !== 'file.png') {
|
||||||
if ($name !== 'file.png') {
|
throw new Exception('Wrong file name', 400, Exception::GENERAL_MOCK);
|
||||||
throw new Exception('Wrong file name', 400, Exception::GENERAL_MOCK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($file['size'] as $i => $size) {
|
if ($file['size'] !== 38756) {
|
||||||
if ($size !== 38756) {
|
|
||||||
throw new Exception('Wrong file size', 400, Exception::GENERAL_MOCK);
|
throw new Exception('Wrong file size', 400, Exception::GENERAL_MOCK);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($file['tmp_name'] as $i => $tmpName) {
|
if (\md5(\file_get_contents($file['tmp_name'])) !== 'd80e7e6999a3eb2ae0d631a96fe135a4') {
|
||||||
if (\md5(\file_get_contents($tmpName)) !== 'd80e7e6999a3eb2ae0d631a96fe135a4') {
|
throw new Exception('Wrong file uploaded', 400, Exception::GENERAL_MOCK);
|
||||||
throw new Exception('Wrong file uploaded', 400, Exception::GENERAL_MOCK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,14 @@ use Utopia\Swoole\Response;
|
||||||
use Utopia\Validator\ArrayList;
|
use Utopia\Validator\ArrayList;
|
||||||
use Utopia\Validator\Assoc;
|
use Utopia\Validator\Assoc;
|
||||||
use Utopia\Validator\Boolean;
|
use Utopia\Validator\Boolean;
|
||||||
use Utopia\Validator\Range as ValidatorRange;
|
use Utopia\Validator\Range;
|
||||||
use Utopia\Validator\Text;
|
use Utopia\Validator\Text;
|
||||||
|
|
||||||
|
|
||||||
Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL);
|
Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL);
|
||||||
|
|
||||||
/** Constants */
|
/** Constants */
|
||||||
const MAINTENANCE_INTERVAL = 1200; // 20 minutes
|
const MAINTENANCE_INTERVAL = 3600; // 3600 seconds = 1 hour
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Swoole table to store runtime information
|
* Create a Swoole table to store runtime information
|
||||||
|
|
@ -395,9 +395,9 @@ App::delete('/v1/runtimes/:runtimeId')
|
||||||
App::post('/v1/execution')
|
App::post('/v1/execution')
|
||||||
->desc('Create an execution')
|
->desc('Create an execution')
|
||||||
->param('runtimeId', '', new Text(64), 'The runtimeID to execute')
|
->param('runtimeId', '', new Text(64), 'The runtimeID to execute')
|
||||||
->param('vars', [], new Assoc(), 'Environment variables required for the build', false)
|
->param('vars', [], new Assoc(), 'Environment variables required for the build')
|
||||||
->param('data', '', new Text(8192), 'Data to be forwarded to the function, this is user specified.', true)
|
->param('data', '{}', new Text(8192), 'Data to be forwarded to the function, this is user specified.', true)
|
||||||
->param('timeout', 15, new ValidatorRange(1, 900), 'Function maximum execution time in seconds.', true)
|
->param('timeout', 15, new Range(1, (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Function maximum execution time in seconds.')
|
||||||
->inject('activeRuntimes')
|
->inject('activeRuntimes')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(
|
->action(
|
||||||
|
|
@ -423,17 +423,19 @@ App::post('/v1/execution')
|
||||||
$errNo = -1;
|
$errNo = -1;
|
||||||
$executorResponse = '';
|
$executorResponse = '';
|
||||||
|
|
||||||
|
$timeout ??= (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900);
|
||||||
|
|
||||||
$ch = \curl_init();
|
$ch = \curl_init();
|
||||||
$body = \json_encode([
|
$body = \json_encode([
|
||||||
'env' => $vars,
|
'env' => $vars,
|
||||||
'payload' => $data,
|
'payload' => $data,
|
||||||
'timeout' => $timeout ?? (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)
|
'timeout' => $timeout
|
||||||
]);
|
]);
|
||||||
\curl_setopt($ch, CURLOPT_URL, "http://" . $runtimeId . ":3000/");
|
\curl_setopt($ch, CURLOPT_URL, "http://" . $runtimeId . ":3000/");
|
||||||
\curl_setopt($ch, CURLOPT_POST, true);
|
\curl_setopt($ch, CURLOPT_POST, true);
|
||||||
\curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
|
\curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
|
||||||
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
\curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ?? (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900));
|
\curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||||
\curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
\curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||||
|
|
||||||
\curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
\curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ void main() { // Init SDK
|
||||||
Future result = storage.createFile(
|
Future result = storage.createFile(
|
||||||
bucketId: '[BUCKET_ID]',
|
bucketId: '[BUCKET_ID]',
|
||||||
fileId: '[FILE_ID]',
|
fileId: '[FILE_ID]',
|
||||||
file: await MultipartFile.fromPath('file', './path-to-files/image.jpg', 'image.jpg'),
|
file: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'),
|
||||||
);
|
);
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ void main() { // Init SDK
|
||||||
Future result = functions.createDeployment(
|
Future result = functions.createDeployment(
|
||||||
functionId: '[FUNCTION_ID]',
|
functionId: '[FUNCTION_ID]',
|
||||||
entrypoint: '[ENTRYPOINT]',
|
entrypoint: '[ENTRYPOINT]',
|
||||||
code: await MultipartFile.fromPath('code', './path-to-files/image.jpg', 'image.jpg'),
|
code: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'),
|
||||||
activate: false,
|
activate: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ void main() { // Init SDK
|
||||||
Future result = storage.createFile(
|
Future result = storage.createFile(
|
||||||
bucketId: '[BUCKET_ID]',
|
bucketId: '[BUCKET_ID]',
|
||||||
fileId: '[FILE_ID]',
|
fileId: '[FILE_ID]',
|
||||||
file: await MultipartFile.fromPath('file', './path-to-files/image.jpg', 'image.jpg'),
|
file: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'),
|
||||||
);
|
);
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
## 4.0.1
|
||||||
|
* Fix InputFile filename param
|
||||||
|
* Fix examples
|
||||||
|
|
||||||
## 4.0.0
|
## 4.0.0
|
||||||
* Support for Appwrite 0.13
|
* Support for Appwrite 0.13
|
||||||
* **BREAKING** **Tags** have been renamed to **Deployments**
|
* **BREAKING** **Tags** have been renamed to **Deployments**
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ Upload File:
|
||||||
```dart
|
```dart
|
||||||
Storage storage = Storage(client);
|
Storage storage = Storage(client);
|
||||||
|
|
||||||
InputFile file = InputFile(path: './path-to-file/image.jpg', fileName: 'image.jpg');
|
InputFile file = InputFile(path: './path-to-file/image.jpg', filename: 'image.jpg');
|
||||||
|
|
||||||
storage.createFile(
|
storage.createFile(
|
||||||
bucketId: '[BUCKET_ID]',
|
bucketId: '[BUCKET_ID]',
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
## 4.0.1
|
||||||
|
* Fix InputFile filename param
|
||||||
|
* Fix examples
|
||||||
|
|
||||||
## 4.0.0
|
## 4.0.0
|
||||||
* Support for Appwrite 0.13
|
* Support for Appwrite 0.13
|
||||||
* **BREAKING** **Tags** have been renamed to **Deployments**
|
* **BREAKING** **Tags** have been renamed to **Deployments**
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@ Storage storage = Storage(client);
|
||||||
late InputFile file;
|
late InputFile file;
|
||||||
|
|
||||||
if(kIsWeb) {
|
if(kIsWeb) {
|
||||||
file = InputFile(file: MultipartFile.fromFile('./path-to-file/image.jpg', filename: 'image.jpg'));
|
file = InputFile(file: await MultipartFile.fromFile('file', './path-to-file/image.jpg', filename: 'image.jpg'));
|
||||||
} else {
|
} else {
|
||||||
file = InputFile(path: './path-to-file/image.jpg', fileName: 'image.jpg');
|
file = InputFile(path: './path-to-file/image.jpg', filename: 'image.jpg');
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.createFile(
|
storage.createFile(
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,9 @@ class Executor
|
||||||
'commands' => $commands
|
'commands' => $commands
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->call(self::METHOD_POST, $route, $headers, $params, true, App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900));
|
$timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900);
|
||||||
|
|
||||||
|
$response = $this->call(self::METHOD_POST, $route, $headers, $params, true, $timeout);
|
||||||
|
|
||||||
$status = $response['headers']['status-code'];
|
$status = $response['headers']['status-code'];
|
||||||
if ($status >= 400) {
|
if ($status >= 400) {
|
||||||
|
|
@ -159,13 +161,18 @@ class Executor
|
||||||
'timeout' => $timeout,
|
'timeout' => $timeout,
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->call(self::METHOD_POST, $route, $headers, $params, true, 30);
|
/* Add 2 seconds as a buffer to the actual timeout value since there can be a slight variance*/
|
||||||
|
$requestTimeout = $timeout + 2;
|
||||||
|
|
||||||
|
$response = $this->call(self::METHOD_POST, $route, $headers, $params, true, $requestTimeout);
|
||||||
$status = $response['headers']['status-code'];
|
$status = $response['headers']['status-code'];
|
||||||
|
|
||||||
if ($status >= 400) {
|
for ($attempts = 0; $attempts < 10; $attempts++) {
|
||||||
for ($attempts = 0; $attempts < 10; $attempts++) {
|
try {
|
||||||
switch ($status) {
|
switch (true) {
|
||||||
case 404:
|
case $status < 400:
|
||||||
|
return $response['body'];
|
||||||
|
case $status === 404:
|
||||||
$response = $this->createRuntime(
|
$response = $this->createRuntime(
|
||||||
deploymentId: $deploymentId,
|
deploymentId: $deploymentId,
|
||||||
projectId: $projectId,
|
projectId: $projectId,
|
||||||
|
|
@ -176,31 +183,23 @@ class Executor
|
||||||
entrypoint: $entrypoint,
|
entrypoint: $entrypoint,
|
||||||
commands: []
|
commands: []
|
||||||
);
|
);
|
||||||
$response = $this->call(self::METHOD_POST, $route, $headers, $params, true, 30);
|
$response = $this->call(self::METHOD_POST, $route, $headers, $params, true, $requestTimeout);
|
||||||
$status = $response['headers']['status-code'];
|
$status = $response['headers']['status-code'];
|
||||||
break;
|
break;
|
||||||
case 406:
|
case $status === 406:
|
||||||
$response = $this->call(self::METHOD_POST, $route, $headers, $params, true, 30);
|
$response = $this->call(self::METHOD_POST, $route, $headers, $params, true, $requestTimeout);
|
||||||
$status = $response['headers']['status-code'];
|
$status = $response['headers']['status-code'];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new \Exception($response['body']['message'], $status);
|
throw new \Exception($response['body']['message'], $status);
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
if ($status < 400) {
|
throw new \Exception($e->getMessage(), $e->getCode());
|
||||||
return $response['body'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($status != 406) {
|
|
||||||
throw new \Exception($response['body']['message'], $status);
|
|
||||||
}
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
}
|
}
|
||||||
throw new Exception($response['body']['message'], 503);
|
sleep(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response['body'];
|
throw new Exception($response['body']['message'], 503);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue