blob: 97aa9d825d51b4087dfbfa5a1b0bad7525b26668 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<?php
namespace Api;
/**
* File API controller
*
* @package api
* @author Frederic Guillot
*/
class File extends \Core\Base
{
public function getFile($file_id)
{
return $this->file->getById($file_id);
}
public function getAllFiles($task_id)
{
return $this->file->getAll($task_id);
}
public function downloadFile($file_id)
{
$file = $this->file->getById($file_id);
if (! empty($file)) {
$filename = FILES_DIR.$file['path'];
if (file_exists($filename)) {
return base64_encode(file_get_contents($filename));
}
}
return '';
}
public function createFile($project_id, $task_id, $filename, $blob)
{
return $this->file->uploadContent($project_id, $task_id, $filename, $blob);
}
public function removeFile($file_id)
{
return $this->file->remove($file_id);
}
public function removeAllFiles($task_id)
{
return $this->file->removeAll($task_id);
}
}
|