Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / files / conduit / FileUploadConduitAPIMethod.php
blob8b3b9faaaa7fa08ebb371499db786a77213d99ea
1 <?php
3 final class FileUploadConduitAPIMethod extends FileConduitAPIMethod {
5 public function getAPIMethodName() {
6 return 'file.upload';
9 public function getMethodDescription() {
10 return pht('Upload a file to the server.');
13 protected function defineParamTypes() {
14 return array(
15 'data_base64' => 'required nonempty base64-bytes',
16 'name' => 'optional string',
17 'viewPolicy' => 'optional valid policy string or <phid>',
18 'canCDN' => 'optional bool',
22 protected function defineReturnType() {
23 return 'nonempty guid';
26 protected function execute(ConduitAPIRequest $request) {
27 $viewer = $request->getUser();
29 $name = $request->getValue('name');
30 $can_cdn = (bool)$request->getValue('canCDN');
31 $view_policy = $request->getValue('viewPolicy');
33 $data = $request->getValue('data_base64');
34 $data = $this->decodeBase64($data);
36 $params = array(
37 'authorPHID' => $viewer->getPHID(),
38 'canCDN' => $can_cdn,
39 'isExplicitUpload' => true,
42 if ($name !== null) {
43 $params['name'] = $name;
46 if ($view_policy !== null) {
47 $params['viewPolicy'] = $view_policy;
50 $file = PhabricatorFile::newFromFileData($data, $params);
52 return $file->getPHID();