Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101677056
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, Feb 12, 16:48
Size
932 B
Mime Type
text/x-php
Expires
Fri, Feb 14, 16:48 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
24210909
Attached To
rPH Phabricator
FileDownloadConduitAPIMethod.php
View Options
<?php
final
class
FileDownloadConduitAPIMethod
extends
FileConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'file.download'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'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'
=>
pht
(
'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