2020-06-24 03:01:20 +12: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-30 02:07:56 +13:00
|
|
|
$this
|
|
|
|
->addRule('$id', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'File ID.',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => '',
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => '5e5ea5c16897e',
|
|
|
|
])
|
|
|
|
->addRule('$permissions', [
|
|
|
|
'type' => Response::MODEL_PERMISSIONS,
|
|
|
|
'description' => 'File permissions.',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => '',
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => new \stdClass,
|
|
|
|
'array' => false,
|
|
|
|
])
|
|
|
|
->addRule('name', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'File name.',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => '',
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => 'Pink.png',
|
|
|
|
])
|
|
|
|
->addRule('dateCreated', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_INTEGER,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'File creation date in Unix timestamp.',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => '',
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => 1592981250,
|
|
|
|
])
|
|
|
|
->addRule('signature', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'File MD5 signature.',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => '',
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => '5d529fd02b544198ae075bd57c1762bb',
|
|
|
|
])
|
|
|
|
->addRule('mimeType', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'File mime type.',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => '',
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => 'image/png',
|
|
|
|
])
|
|
|
|
->addRule('sizeOriginal', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_INTEGER,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'File original size in bytes.',
|
2021-01-14 05:10:42 +13:00
|
|
|
'default' => 0,
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => 17890,
|
|
|
|
])
|
|
|
|
;
|
2020-06-24 03:01:20 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Name
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getName():string
|
|
|
|
{
|
|
|
|
return 'File';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Collection
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getType():string
|
|
|
|
{
|
2020-10-30 02:07:56 +13:00
|
|
|
return Response::MODEL_FILE;
|
2020-06-24 03:01:20 +12:00
|
|
|
}
|
|
|
|
}
|