Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/conduit/FileAllocateConduitAPIMethod.php
| Show All 11 Lines | final class FileAllocateConduitAPIMethod | ||||
| } | } | ||||
| protected function defineParamTypes() { | protected function defineParamTypes() { | ||||
| return array( | return array( | ||||
| 'name' => 'string', | 'name' => 'string', | ||||
| 'contentLength' => 'int', | 'contentLength' => 'int', | ||||
| 'contentHash' => 'optional string', | 'contentHash' => 'optional string', | ||||
| 'viewPolicy' => 'optional string', | 'viewPolicy' => 'optional string', | ||||
| 'deleteAfterEpoch' => 'optional int', | |||||
| ); | ); | ||||
| } | } | ||||
| protected function defineReturnType() { | protected function defineReturnType() { | ||||
| return 'map<string, wild>'; | return 'map<string, wild>'; | ||||
| } | } | ||||
| protected function execute(ConduitAPIRequest $request) { | protected function execute(ConduitAPIRequest $request) { | ||||
| $viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
| $hash = $request->getValue('contentHash'); | $hash = $request->getValue('contentHash'); | ||||
| $name = $request->getValue('name'); | $name = $request->getValue('name'); | ||||
| $view_policy = $request->getValue('viewPolicy'); | $view_policy = $request->getValue('viewPolicy'); | ||||
| $length = $request->getValue('contentLength'); | $length = $request->getValue('contentLength'); | ||||
| $properties = array( | $properties = array( | ||||
| 'name' => $name, | 'name' => $name, | ||||
| 'authorPHID' => $viewer->getPHID(), | 'authorPHID' => $viewer->getPHID(), | ||||
| 'viewPolicy' => $view_policy, | 'viewPolicy' => $view_policy, | ||||
| 'isExplicitUpload' => true, | 'isExplicitUpload' => true, | ||||
| ); | ); | ||||
| $ttl = $request->getValue('deleteAfterEpoch'); | |||||
| if ($ttl) { | |||||
| $properties['ttl'] = $ttl; | |||||
| } | |||||
| $file = null; | $file = null; | ||||
| if ($hash) { | if ($hash) { | ||||
| $file = PhabricatorFile::newFileFromContentHash( | $file = PhabricatorFile::newFileFromContentHash( | ||||
| $hash, | $hash, | ||||
| $properties); | $properties); | ||||
| } | } | ||||
| if ($hash && !$file) { | if ($hash && !$file) { | ||||
| ▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines | |||||