Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/conduit/FileUploadConduitAPIMethod.php
Show All 25 Lines | final class FileUploadConduitAPIMethod extends FileConduitAPIMethod { | ||||
protected function execute(ConduitAPIRequest $request) { | protected function execute(ConduitAPIRequest $request) { | ||||
$viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
$name = $request->getValue('name'); | $name = $request->getValue('name'); | ||||
$can_cdn = (bool)$request->getValue('canCDN'); | $can_cdn = (bool)$request->getValue('canCDN'); | ||||
$view_policy = $request->getValue('viewPolicy'); | $view_policy = $request->getValue('viewPolicy'); | ||||
$data = $request->getValue('data_base64'); | $data = $request->getValue('data_base64'); | ||||
if (!phutil_nonempty_string($data)) { | |||||
speck: This is probably fine to use phutil non empty string, or also check if strlen. This exception… | |||||
throw new Exception(pht('Field "data_base64" must be non-empty.')); | |||||
Not Done Inline ActionsCould you update this to better indicate the user/caller error?
Or similar speck: Could you update this to better indicate the user/caller error?
> Field “data_base64” must be… | |||||
} | |||||
$data = $this->decodeBase64($data); | $data = $this->decodeBase64($data); | ||||
$params = array( | $params = array( | ||||
'authorPHID' => $viewer->getPHID(), | 'authorPHID' => $viewer->getPHID(), | ||||
'canCDN' => $can_cdn, | 'canCDN' => $can_cdn, | ||||
'isExplicitUpload' => true, | 'isExplicitUpload' => true, | ||||
); | ); | ||||
if ($name !== null) { | if ($name !== null) { | ||||
$params['name'] = $name; | $params['name'] = $name; | ||||
Show All 12 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
This is probably fine to use phutil non empty string, or also check if strlen. This exception should be hit for both cases of the field being omitted and also if the field is present but has the value of empty string.