mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-04 02:14:06 +02:00
Add php-cs-fixer
This commit is contained in:
parent
e00e6ece5f
commit
309ae17036
54 changed files with 4900 additions and 4106 deletions
|
|
@ -4,36 +4,36 @@ use Demostf\API\Providers\UploadProvider;
|
|||
use flight\Engine;
|
||||
|
||||
class UploadController extends BaseController {
|
||||
private $uploadProvider;
|
||||
private $uploadProvider;
|
||||
|
||||
public function __construct(UploadProvider $uploadProvider) {
|
||||
$this->uploadProvider = $uploadProvider;
|
||||
}
|
||||
public function __construct(UploadProvider $uploadProvider) {
|
||||
$this->uploadProvider = $uploadProvider;
|
||||
}
|
||||
|
||||
public function upload() {
|
||||
$key = $this->post('key', '');
|
||||
$red = $this->post('red', 'RED');
|
||||
$blu = $this->post('blu', 'BLU');
|
||||
$name = $this->post('name', 'Unnamed');
|
||||
$demo = $this->file('demo');
|
||||
if (is_null($demo)) {
|
||||
echo 'No demo uploaded';
|
||||
return;
|
||||
}
|
||||
$demoFile = $demo['tmp_name'];
|
||||
public function upload() {
|
||||
$key = $this->post('key', '');
|
||||
$red = $this->post('red', 'RED');
|
||||
$blu = $this->post('blu', 'BLU');
|
||||
$name = $this->post('name', 'Unnamed');
|
||||
$demo = $this->file('demo');
|
||||
if (is_null($demo)) {
|
||||
echo 'No demo uploaded';
|
||||
return;
|
||||
}
|
||||
$demoFile = $demo['tmp_name'];
|
||||
|
||||
try {
|
||||
$result = $this->uploadProvider->upload($key, $red, $blu, $name, $demoFile);
|
||||
if ($result === 'Invalid key') {
|
||||
\Flight::response()->status(401)->write($result)->send();
|
||||
} else {
|
||||
echo $result;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Flight::response()
|
||||
->status(500)
|
||||
->write($e->getMessage())
|
||||
->send();
|
||||
}
|
||||
}
|
||||
try {
|
||||
$result = $this->uploadProvider->upload($key, $red, $blu, $name, $demoFile);
|
||||
if ($result === 'Invalid key') {
|
||||
\Flight::response()->status(401)->write($result)->send();
|
||||
} else {
|
||||
echo $result;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Flight::response()
|
||||
->status(500)
|
||||
->write($e->getMessage())
|
||||
->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue