Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/conduit/FileUploadHashConduitAPIMethod.php
<?php | <?php | ||||
final class FileUploadHashConduitAPIMethod extends FileConduitAPIMethod { | final class FileUploadHashConduitAPIMethod extends FileConduitAPIMethod { | ||||
public function getAPIMethodName() { | public function getAPIMethodName() { | ||||
// TODO: Deprecate this in favor of `file.allocate`. | // TODO: Deprecate this in favor of `file.allocate`. | ||||
return 'file.uploadhash'; | return 'file.uploadhash'; | ||||
} | } | ||||
public function getMethodDescription() { | public function getMethodDescription() { | ||||
return 'Upload a file to the server using content hash.'; | return 'Upload a file to the server using content hash.'; | ||||
} | } | ||||
public function defineParamTypes() { | protected function defineParamTypes() { | ||||
return array( | return array( | ||||
'hash' => 'required nonempty string', | 'hash' => 'required nonempty string', | ||||
'name' => 'required nonempty string', | 'name' => 'required nonempty string', | ||||
); | ); | ||||
} | } | ||||
public function defineReturnType() { | protected function defineReturnType() { | ||||
return 'phid or null'; | return 'phid or null'; | ||||
} | } | ||||
public function defineErrorTypes() { | |||||
return array( | |||||
); | |||||
} | |||||
protected function execute(ConduitAPIRequest $request) { | protected function execute(ConduitAPIRequest $request) { | ||||
$hash = $request->getValue('hash'); | $hash = $request->getValue('hash'); | ||||
$name = $request->getValue('name'); | $name = $request->getValue('name'); | ||||
$user = $request->getUser(); | $user = $request->getUser(); | ||||
$file = PhabricatorFile::newFileFromContentHash( | $file = PhabricatorFile::newFileFromContentHash( | ||||
$hash, | $hash, | ||||
array( | array( | ||||
Show All 11 Lines |