2020-06-23 15:01:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
|
|
|
|
use Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
|
|
class File extends Model
|
|
|
|
|
{
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
2020-10-29 13:07:56 +00:00
|
|
|
$this
|
|
|
|
|
->addRule('$id', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-29 13:07:56 +00:00
|
|
|
'description' => 'File ID.',
|
2021-01-13 15:06:36 +00:00
|
|
|
'default' => '',
|
2020-10-29 13:07:56 +00:00
|
|
|
'example' => '5e5ea5c16897e',
|
|
|
|
|
])
|
2021-10-21 09:41:05 +00:00
|
|
|
->addRule('bucketId', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Bucket ID.',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => '5e5ea5c16897e',
|
2020-10-29 13:07:56 +00:00
|
|
|
])
|
2022-06-15 12:46:52 +00:00
|
|
|
->addRule('$createdAt', [
|
2022-07-04 09:55:11 +00:00
|
|
|
'type' => self::TYPE_DATETIME,
|
2022-09-04 21:26:16 +00:00
|
|
|
'description' => 'File creation date in ISO 8601 format.',
|
2022-07-04 09:55:11 +00:00
|
|
|
'default' => '',
|
2022-08-14 10:27:07 +00:00
|
|
|
'example' => self::TYPE_DATETIME_EXAMPLE,
|
2022-06-15 12:46:52 +00:00
|
|
|
])
|
|
|
|
|
->addRule('$updatedAt', [
|
2022-07-04 09:55:11 +00:00
|
|
|
'type' => self::TYPE_DATETIME,
|
2022-09-04 21:26:16 +00:00
|
|
|
'description' => 'File update date in ISO 8601 format.',
|
2022-07-04 09:55:11 +00:00
|
|
|
'default' => '',
|
2022-08-14 10:27:07 +00:00
|
|
|
'example' => self::TYPE_DATETIME_EXAMPLE,
|
2022-06-15 12:46:52 +00:00
|
|
|
])
|
2022-08-02 09:19:15 +00:00
|
|
|
->addRule('$permissions', [
|
2021-05-03 22:20:40 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2023-10-13 13:43:44 +00:00
|
|
|
'description' => 'File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).',
|
2021-05-03 22:20:40 +00:00
|
|
|
'default' => [],
|
2022-08-14 10:33:36 +00:00
|
|
|
'example' => ['read("any")'],
|
2021-05-03 22:20:40 +00:00
|
|
|
'array' => true,
|
2020-10-29 13:07:56 +00:00
|
|
|
])
|
|
|
|
|
->addRule('name', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-29 13:07:56 +00:00
|
|
|
'description' => 'File name.',
|
2021-01-13 15:06:36 +00:00
|
|
|
'default' => '',
|
2020-10-29 13:07:56 +00:00
|
|
|
'example' => 'Pink.png',
|
|
|
|
|
])
|
|
|
|
|
->addRule('signature', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-29 13:07:56 +00:00
|
|
|
'description' => 'File MD5 signature.',
|
2021-01-13 15:06:36 +00:00
|
|
|
'default' => '',
|
2020-10-29 13:07:56 +00:00
|
|
|
'example' => '5d529fd02b544198ae075bd57c1762bb',
|
|
|
|
|
])
|
|
|
|
|
->addRule('mimeType', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-29 13:07:56 +00:00
|
|
|
'description' => 'File mime type.',
|
2021-01-13 15:06:36 +00:00
|
|
|
'default' => '',
|
2020-10-29 13:07:56 +00:00
|
|
|
'example' => 'image/png',
|
|
|
|
|
])
|
|
|
|
|
->addRule('sizeOriginal', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_INTEGER,
|
2020-10-29 13:07:56 +00:00
|
|
|
'description' => 'File original size in bytes.',
|
2021-01-13 16:10:42 +00:00
|
|
|
'default' => 0,
|
2020-10-29 13:07:56 +00:00
|
|
|
'example' => 17890,
|
|
|
|
|
])
|
2021-07-13 07:42:03 +00:00
|
|
|
->addRule('chunksTotal', [
|
2021-07-07 10:07:11 +00:00
|
|
|
'type' => self::TYPE_INTEGER,
|
|
|
|
|
'description' => 'Total number of chunks available',
|
|
|
|
|
'default' => 0,
|
|
|
|
|
'example' => 17890,
|
|
|
|
|
])
|
2021-07-13 07:42:03 +00:00
|
|
|
->addRule('chunksUploaded', [
|
2021-07-07 10:07:11 +00:00
|
|
|
'type' => self::TYPE_INTEGER,
|
|
|
|
|
'description' => 'Total number of chunks uploaded',
|
|
|
|
|
'default' => 0,
|
|
|
|
|
'example' => 17890,
|
|
|
|
|
])
|
2020-10-29 13:07:56 +00:00
|
|
|
;
|
2020-06-23 15:01:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Name
|
2021-10-06 14:22:38 +00:00
|
|
|
*
|
2020-06-23 15:01:20 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2022-05-23 14:54:50 +00:00
|
|
|
public function getName(): string
|
2020-06-23 15:01:20 +00:00
|
|
|
{
|
|
|
|
|
return 'File';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-12-15 10:19:29 +00:00
|
|
|
* Get Type
|
2021-10-06 14:22:38 +00:00
|
|
|
*
|
2020-06-23 15:01:20 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2022-05-23 14:54:50 +00:00
|
|
|
public function getType(): string
|
2020-06-23 15:01:20 +00:00
|
|
|
{
|
2020-10-29 13:07:56 +00:00
|
|
|
return Response::MODEL_FILE;
|
2020-06-23 15:01:20 +00:00
|
|
|
}
|
2021-07-13 07:42:03 +00:00
|
|
|
}
|