This repository has been archived on 2025-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
szurubooru/src/FormData/UploadFormData.php
Marcin Kurczewski f2b1e3bedb Changed post uploads
Post uploads no longer encapsulates file content in base64.
This means dramatic speed up for sending on local networks.
2014-11-22 14:37:00 +01:00

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);
}
}