3 final class FileInfoConduitAPIMethod
extends FileConduitAPIMethod
{
5 public function getAPIMethodName() {
9 public function getMethodDescription() {
10 return pht('Get information about a file.');
13 public function getMethodStatus() {
14 return self
::METHOD_STATUS_FROZEN
;
17 public function getMethodStatusDescription() {
19 'This method is frozen and will eventually be deprecated. New code '.
20 'should use "file.search" instead.');
23 protected function defineParamTypes() {
25 'phid' => 'optional phid',
26 'id' => 'optional id',
30 protected function defineReturnType() {
31 return 'nonempty dict';
34 protected function defineErrorTypes() {
36 'ERR-NOT-FOUND' => pht('No such file exists.'),
40 protected function execute(ConduitAPIRequest
$request) {
41 $phid = $request->getValue('phid');
42 $id = $request->getValue('id');
44 $query = id(new PhabricatorFileQuery())
45 ->setViewer($request->getUser());
47 $query->withIDs(array($id));
49 $query->withPHIDs(array($phid));
52 $file = $query->executeOne();
55 throw new ConduitException('ERR-NOT-FOUND');
58 $uri = $file->getInfoURI();
61 'id' => $file->getID(),
62 'phid' => $file->getPHID(),
63 'objectName' => 'F'.$file->getID(),
64 'name' => $file->getName(),
65 'mimeType' => $file->getMimeType(),
66 'byteSize' => $file->getByteSize(),
67 'authorPHID' => $file->getAuthorPHID(),
68 'dateCreated' => $file->getDateCreated(),
69 'dateModified' => $file->getDateModified(),
70 'uri' => PhabricatorEnv
::getProductionURI($uri),