2013-02-11 15:30:02 +01:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
final class FileUploadHashConduitAPIMethod extends FileConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'file.uploadhash';
|
|
|
|
}
|
2013-02-11 15:30:02 +01:00
|
|
|
|
|
|
|
public function getMethodDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return 'Upload a file to the server using content hash.';
|
2013-02-11 15:30:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function defineParamTypes() {
|
|
|
|
return array(
|
|
|
|
'hash' => 'required nonempty string',
|
|
|
|
'name' => 'required nonempty string',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineReturnType() {
|
|
|
|
return 'phid or null';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineErrorTypes() {
|
|
|
|
return array(
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
|
|
$hash = $request->getValue('hash');
|
|
|
|
$name = $request->getValue('name');
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$file = PhabricatorFile::newFileFromContentHash(
|
|
|
|
$hash,
|
|
|
|
array(
|
|
|
|
'name' => $name,
|
|
|
|
'authorPHID' => $user->getPHID(),
|
|
|
|
));
|
|
|
|
|
|
|
|
if ($file) {
|
|
|
|
return $file->getPHID();
|
|
|
|
}
|
|
|
|
return $file;
|
|
|
|
}
|
2014-07-10 00:12:48 +02:00
|
|
|
|
2013-02-11 15:30:02 +01:00
|
|
|
}
|