Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/files/conduit/FileQueryChunksConduitAPIMethod.php
12241 views
1
<?php
2
3
final class FileQueryChunksConduitAPIMethod
4
extends FileConduitAPIMethod {
5
6
public function getAPIMethodName() {
7
return 'file.querychunks';
8
}
9
10
public function getMethodDescription() {
11
return pht('Get information about file chunks.');
12
}
13
14
protected function defineParamTypes() {
15
return array(
16
'filePHID' => 'phid',
17
);
18
}
19
20
protected function defineReturnType() {
21
return 'list<wild>';
22
}
23
24
protected function execute(ConduitAPIRequest $request) {
25
$viewer = $request->getUser();
26
27
$file_phid = $request->getValue('filePHID');
28
$file = $this->loadFileByPHID($viewer, $file_phid);
29
$chunks = $this->loadFileChunks($viewer, $file);
30
31
$results = array();
32
foreach ($chunks as $chunk) {
33
$results[] = array(
34
'byteStart' => $chunk->getByteStart(),
35
'byteEnd' => $chunk->getByteEnd(),
36
'complete' => (bool)$chunk->getDataFilePHID(),
37
);
38
}
39
40
return $results;
41
}
42
43
}
44
45