[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/files/conduit/ -> FileDownloadConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class FileDownloadConduitAPIMethod extends FileConduitAPIMethod {
   4  
   5    public function getAPIMethodName() {
   6      return 'file.download';
   7    }
   8  
   9    public function getMethodDescription() {
  10      return 'Download a file from the server.';
  11    }
  12  
  13    public function defineParamTypes() {
  14      return array(
  15        'phid' => 'required phid',
  16      );
  17    }
  18  
  19    public function defineReturnType() {
  20      return 'nonempty base64-bytes';
  21    }
  22  
  23    public function defineErrorTypes() {
  24      return array(
  25        'ERR-BAD-PHID' => 'No such file exists.',
  26      );
  27    }
  28  
  29    protected function execute(ConduitAPIRequest $request) {
  30      $phid = $request->getValue('phid');
  31  
  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');
  38      }
  39  
  40      return base64_encode($file->loadFileData());
  41    }
  42  
  43  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1