Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F109793200
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
Wed, Apr 23, 10:11
Size
922 B
Mime Type
text/x-php
Expires
Fri, Apr 25, 10:11 (2 d)
Engine
blob
Format
Raw Data
Handle
25696791
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.'
;
}
protected
function
defineParamTypes
()
{
return
array
(
'phid'
=>
'required phid'
,
);
}
protected
function
defineReturnType
()
{
return
'nonempty base64-bytes'
;
}
protected
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