Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/files/conduit/FileUploadConduitAPIMethod.php b/src/applications/files/conduit/FileUploadConduitAPIMethod.php
index 8b3b9faaaa..cafe842596 100644
--- a/src/applications/files/conduit/FileUploadConduitAPIMethod.php
+++ b/src/applications/files/conduit/FileUploadConduitAPIMethod.php
@@ -1,55 +1,57 @@
<?php
final class FileUploadConduitAPIMethod extends FileConduitAPIMethod {
public function getAPIMethodName() {
return 'file.upload';
}
public function getMethodDescription() {
return pht('Upload a file to the server.');
}
protected function defineParamTypes() {
return array(
'data_base64' => 'required nonempty base64-bytes',
'name' => 'optional string',
'viewPolicy' => 'optional valid policy string or <phid>',
'canCDN' => 'optional bool',
);
}
protected function defineReturnType() {
return 'nonempty guid';
}
protected function execute(ConduitAPIRequest $request) {
$viewer = $request->getUser();
$name = $request->getValue('name');
$can_cdn = (bool)$request->getValue('canCDN');
$view_policy = $request->getValue('viewPolicy');
$data = $request->getValue('data_base64');
+ if (!phutil_nonempty_string($data)) {
+ throw new Exception(pht('Field "data_base64" must be non-empty.'));
+ }
$data = $this->decodeBase64($data);
-
$params = array(
'authorPHID' => $viewer->getPHID(),
'canCDN' => $can_cdn,
'isExplicitUpload' => true,
);
if ($name !== null) {
$params['name'] = $name;
}
if ($view_policy !== null) {
$params['viewPolicy'] = $view_policy;
}
$file = PhabricatorFile::newFromFileData($data, $params);
return $file->getPHID();
}
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Mar 14, 12:41 PM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
71874
Default Alt Text
(1 KB)

Event Timeline