Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / files / conduit / FileDownloadConduitAPIMethod.php
blob3a3867ac9e18bdf3cc8b62784e23307bd0151409
1 <?php
3 final class FileDownloadConduitAPIMethod extends FileConduitAPIMethod {
5 public function getAPIMethodName() {
6 return 'file.download';
9 public function getMethodDescription() {
10 return pht('Download a file from the server.');
13 protected function defineParamTypes() {
14 return array(
15 'phid' => 'required phid',
19 protected function defineReturnType() {
20 return 'nonempty base64-bytes';
23 protected function defineErrorTypes() {
24 return array(
25 'ERR-BAD-PHID' => pht('No such file exists.'),
29 protected function execute(ConduitAPIRequest $request) {
30 $phid = $request->getValue('phid');
32 $file = id(new PhabricatorFileQuery())
33 ->setViewer($request->getUser())
34 ->withPHIDs(array($phid))
35 ->executeOne();
36 if (!$file) {
37 throw new ConduitException('ERR-BAD-PHID');
40 return base64_encode($file->loadFileData());