Page MenuHomePhorge

FileDownloadConduitAPIMethod.php
No OneTemporary

Size
932 B
Referenced Files
None
Subscribers
None

FileDownloadConduitAPIMethod.php

<?php
final class FileDownloadConduitAPIMethod extends FileConduitAPIMethod {
public function getAPIMethodName() {
return 'file.download';
}
public function getMethodDescription() {
return pht('Download a file from the server.');
}
protected function defineParamTypes() {
return array(
'phid' => 'required phid',
);
}
protected function defineReturnType() {
return 'nonempty base64-bytes';
}
protected function defineErrorTypes() {
return array(
'ERR-BAD-PHID' => pht('No such file exists.'),
);
}
protected function execute(ConduitAPIRequest $request) {
$phid = $request->getValue('phid');
$file = id(new PhabricatorFileQuery())
->setViewer($request->getUser())
->withPHIDs(array($phid))
->executeOne();
if (!$file) {
throw new ConduitException('ERR-BAD-PHID');
}
return base64_encode($file->loadFileData());
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, May 12, 1:38 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
119960
Default Alt Text
FileDownloadConduitAPIMethod.php (932 B)

Event Timeline