Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F106143432
FileDownloadConduitAPIMethod.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
Sun, Mar 23, 02:29
Size
913 B
Mime Type
text/x-php
Expires
Tue, Mar 25, 02:29 (2 d)
Engine
blob
Format
Raw Data
Handle
25061346
Attached To
rPH Phabricator
FileDownloadConduitAPIMethod.php
View Options
<?php
final
class
FileDownloadConduitAPIMethod
extends
FileConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'file.download'
;
}
public
function
getMethodDescription
()
{
return
'Download a file from the server.'
;
}
public
function
defineParamTypes
()
{
return
array
(
'phid'
=>
'required phid'
,
);
}
public
function
defineReturnType
()
{
return
'nonempty base64-bytes'
;
}
public
function
defineErrorTypes
()
{
return
array
(
'ERR-BAD-PHID'
=>
'No such file exists.'
,
);
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$phid
=
$request
->
getValue
(
'phid'
);
$file
=
id
(
new
PhabricatorFileQuery
())
->
setViewer
(
$request
->
getUser
())
->
withPHIDs
(
array
(
$phid
))
->
executeOne
();
if
(!
$file
)
{
throw
new
ConduitException
(
'ERR-BAD-PHID'
);
}
return
base64_encode
(
$file
->
loadFileData
());
}
}
Event Timeline
Log In to Comment