Post uploads no longer encapsulates file content in base64. This means dramatic speed up for sending on local networks.
42 lines
1 KiB
PHP
42 lines
1 KiB
PHP
<?php
|
|
namespace Szurubooru\FormData;
|
|
use Szurubooru\Helpers\EnumHelper;
|
|
use Szurubooru\IValidatable;
|
|
use Szurubooru\Validator;
|
|
|
|
class UploadFormData implements IValidatable
|
|
{
|
|
public $contentFileName;
|
|
public $content;
|
|
public $url;
|
|
public $anonymous;
|
|
public $safety;
|
|
public $source;
|
|
public $tags;
|
|
|
|
public function __construct($inputReader = null)
|
|
{
|
|
if ($inputReader !== null)
|
|
{
|
|
$this->contentFileName = $inputReader->contentFileName;
|
|
$this->content = $inputReader->readFile('content');
|
|
$this->url = $inputReader->url;
|
|
$this->anonymous = $inputReader->anonymous;
|
|
$this->safety = EnumHelper::postSafetyFromString($inputReader->safety);
|
|
$this->source = $inputReader->source;
|
|
$this->tags = preg_split('/[\s+]/', $inputReader->tags);
|
|
}
|
|
}
|
|
|
|
public function validate(Validator $validator)
|
|
{
|
|
if ($this->content === null && $this->url === null)
|
|
throw new \DomainException('Neither data or URL provided.');
|
|
|
|
$validator->validatePostTags($this->tags);
|
|
|
|
if ($this->source !== null)
|
|
$validator->validatePostSource($this->source);
|
|
}
|
|
}
|
|
|