-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFlowJs.php
78 lines (66 loc) · 1.83 KB
/
FlowJs.php
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace leammas\yii2\flowjs;
use Yii;
use yii\base\Module;
/**
* Main module class
*
* @author Самойлов Владимир <[email protected]>
*/
class FlowJs extends Module
{
public $controllerNamespace = 'leammas\yii2\flowjs';
/**
* Completely uploaded files folder
* @var string
*/
public $targetDir = '@runtime/flowjs';
/**
* Chunks folder
* @var string
*/
public $tempDir = '@runtime/flowjs-temp';
/**
* A callable to process the name of the uploaded file . May be used to avoid collisions.
* @var callable
*/
public $fileNameHandler;
/**
* Pass TRUE in config if you'd like to allow accepting upload requests from another domain.
* This could be a security issue if enabled!
* @var bool
*/
public $allowCrossDomain = false;
/**
* With $allowCrossDomain enabled allows client to pass headers listed in this variable.
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Access-Control-Allow-Headers
* @var array
*/
public $allowCORSHeaders = '';
/**
* @var string
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Access-Control-Allow-Origin
*/
public $allowCORSOrigin = '*';
/**
* Checks whether dir exists if not, tries to create it
* @param $path
* @throws \RuntimeException
* @return void
*/
protected function checkDir($path)
{
if (!is_dir(realpath($path)))
{
if (!mkdir($path, 0666))
{
throw new \RuntimeException("FlowJs can't create {$path} folder.");
}
}
}
public function init()
{
$this->checkDir(Yii::getAlias($this->tempDir));
$this->checkDir(Yii::getAlias($this->targetDir));
}
}