diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index d6ed7a22b5..5f1a31bca8 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -96,6 +96,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'applications/conduit/method/differential/updatetaskrevisionassoc', 'ConduitAPI_diffusion_getcommits_Method' => 'applications/conduit/method/diffusion/getcommits', 'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'applications/conduit/method/diffusion/getrecentcommitsbypath', + 'ConduitAPI_file_download_Method' => 'applications/conduit/method/file/download', 'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload', 'ConduitAPI_path_getowners_Method' => 'applications/conduit/method/path/getowners', 'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find', @@ -593,6 +594,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'ConduitAPIMethod', 'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod', 'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'ConduitAPIMethod', + 'ConduitAPI_file_download_Method' => 'ConduitAPIMethod', 'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod', 'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod', 'ConduitAPI_user_find_Method' => 'ConduitAPIMethod', diff --git a/src/applications/conduit/method/file/download/ConduitAPI_file_download_Method.php b/src/applications/conduit/method/file/download/ConduitAPI_file_download_Method.php new file mode 100644 index 0000000000..989b26c941 --- /dev/null +++ b/src/applications/conduit/method/file/download/ConduitAPI_file_download_Method.php @@ -0,0 +1,54 @@ + 'required phid', + ); + } + + public function defineReturnType() { + return 'nonempty base64-bytes'; + } + + public function defineErrorTypes() { + return array( + 'ERR-BAD-PHID' => 'No such file exists.', + ); + } + + protected function execute(ConduitAPIRequest $request) { + $phid = $request->getValue('phid'); + + $file = id(new PhabricatorFile())->loadOneWhere( + 'phid = %s', + $phid); + if (!$file) { + throw new ConduitException('ERR-BAD-PHID'); + } + + return base64_encode($file->loadFileData()); + } + +} diff --git a/src/applications/conduit/method/file/download/__init__.php b/src/applications/conduit/method/file/download/__init__.php new file mode 100644 index 0000000000..e073903b6d --- /dev/null +++ b/src/applications/conduit/method/file/download/__init__.php @@ -0,0 +1,16 @@ +