diff --git a/src/applications/files/conduit/FileUploadConduitAPIMethod.php b/src/applications/files/conduit/FileUploadConduitAPIMethod.php index 14b2594dbc..389e314333 100644 --- a/src/applications/files/conduit/FileUploadConduitAPIMethod.php +++ b/src/applications/files/conduit/FileUploadConduitAPIMethod.php @@ -14,6 +14,8 @@ final class FileUploadConduitAPIMethod extends FileConduitAPIMethod { return array( 'data_base64' => 'required nonempty base64-bytes', 'name' => 'optional string', + 'viewPolicy' => 'optional valid policy string or ', + 'canCDN' => 'optional bool', ); } @@ -29,15 +31,26 @@ final class FileUploadConduitAPIMethod extends FileConduitAPIMethod { protected function execute(ConduitAPIRequest $request) { $data = $request->getValue('data_base64'); $name = $request->getValue('name'); - $data = base64_decode($data, $strict = true); + $can_cdn = $request->getValue('canCDN'); + $view_policy = $request->getValue('viewPolicy'); + $user = $request->getUser(); + $data = base64_decode($data, $strict = true); + + if (!$view_policy) { + $view_policy = PhabricatorPolicies::getMostOpenPolicy(); + } $file = PhabricatorFile::newFromFileData( $data, array( 'name' => $name, 'authorPHID' => $user->getPHID(), + 'viewPolicy' => $view_policy, + 'canCDN' => $can_cdn, + 'isExplicitUpload' => true, )); + return $file->getPHID(); }