Files

38 lines
1000 B
PHP
Raw Permalink Normal View History

2019-05-27 15:30:49 -07:00
<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2019-05-27 15:30:49 -07:00
namespace Pterodactyl\Http\Requests\Api\Client\Servers\Files;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Enum\Permissions;
2019-05-27 15:30:49 -07:00
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
use Pterodactyl\Models\Server;
2019-05-27 15:30:49 -07:00
class WriteFileContentRequest extends ClientApiRequest
2019-05-27 15:30:49 -07:00
{
/**
* {@inheritdoc}
2019-05-27 15:30:49 -07:00
*/
public function authorize(): bool
2019-05-27 15:30:49 -07:00
{
$server = $this->parameter('server', Server::class);
return $this->user()->can(Permissions::FileCreate->value, $server)
|| $this->user()->can(Permissions::FileUpdate->value, $server);
2019-05-27 15:30:49 -07:00
}
/**
* There is no rule here for the file contents since we just use the body content
* on the request to set the file contents. If nothing is passed that is fine since
* it just means we want to set the file to be empty.
2026-10-05 18:10:18 -04:00
*
* @return ValidationRules
2019-05-27 15:30:49 -07:00
*/
public function rules(): array
{
return [
'file' => ['required', 'string', 'max:2048'],
2019-05-27 15:30:49 -07:00
];
}
}