Path: blob/master/src/applications/files/conduit/FileDownloadConduitAPIMethod.php
12241 views
<?php12final class FileDownloadConduitAPIMethod extends FileConduitAPIMethod {34public function getAPIMethodName() {5return 'file.download';6}78public function getMethodDescription() {9return pht('Download a file from the server.');10}1112protected function defineParamTypes() {13return array(14'phid' => 'required phid',15);16}1718protected function defineReturnType() {19return 'nonempty base64-bytes';20}2122protected function defineErrorTypes() {23return array(24'ERR-BAD-PHID' => pht('No such file exists.'),25);26}2728protected function execute(ConduitAPIRequest $request) {29$phid = $request->getValue('phid');3031$file = id(new PhabricatorFileQuery())32->setViewer($request->getUser())33->withPHIDs(array($phid))34->executeOne();35if (!$file) {36throw new ConduitException('ERR-BAD-PHID');37}3839return base64_encode($file->loadFileData());40}4142}434445