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() {
15 'phid' => 'required phid',
19 protected function defineReturnType() {
20 return 'nonempty base64-bytes';
23 protected function defineErrorTypes() {
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))
37 throw new ConduitException('ERR-BAD-PHID');
40 return base64_encode($file->loadFileData());