Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91558550
FileUploadConduitAPIMethod.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 12, 05:08
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Nov 14, 05:08 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22283072
Attached To
rPH Phabricator
FileUploadConduitAPIMethod.php
View Options
<?php
final
class
FileUploadConduitAPIMethod
extends
FileConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'file.upload'
;
}
public
function
getMethodDescription
()
{
return
'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
=
$request
->
getValue
(
'canCDN'
);
$view_policy
=
$request
->
getValue
(
'viewPolicy'
);
$data
=
$request
->
getValue
(
'data_base64'
);
$data
=
$this
->
decodeBase64
(
$data
);
$file
=
PhabricatorFile
::
newFromFileData
(
$data
,
array
(
'name'
=>
$name
,
'authorPHID'
=>
$viewer
->
getPHID
(),
'viewPolicy'
=>
$view_policy
,
'canCDN'
=>
$can_cdn
,
'isExplicitUpload'
=>
true
,
));
return
$file
->
getPHID
();
}
}
Event Timeline
Log In to Comment