-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathConfig.php
More file actions
135 lines (110 loc) · 3.06 KB
/
Config.php
File metadata and controls
135 lines (110 loc) · 3.06 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
namespace Upyun;
/**
* Class Config
*
* @package Upyun
*/
class Config
{
/**
* @var string 服务名称
*/
public $bucketName;
/**
* @var string 操作员名
*/
public $operatorName;
/**
* @var string 操作员密码 md5 hash 值
*/
public $operatorPassword;
/**
* @var bool 是否使用 https
*/
public $useSsl;
/**
* @var string 上传使用的接口类型,可以设置为 `REST`:使用 rest api 上传,`AUTO` 根据文件大小自动判断,`BLOCK` 使用断点续传
* 当上传小文件时,不推荐使用断点续传;上传时如果设置了异步预处理`withAsyncProcess=true`,将会使用表单 api 上传
*/
public $uploadType = 'AUTO';
/**
* @var int 上传的接口类型设置为 `AUTO` 时,文件大小的边界值:小于该值时,使用 rest api,否则使用断点续传。 默认 30M
*/
public $sizeBoundary = 31457280;
/**
* @var int 分块上传`Multi`接口的最大分块值
*/
public $maxBlockSize = 5242880;
/**
* @var int 分块时,每个块的过期时间
*/
public $blockExpiration = 60;
/**
* @var int request timeout seconds
*/
public $timeout = 60;
/**
* @var string 异步云处理的回调通知地址
*/
public $processNotifyUrl;
/**
* @var boolean curl debug
*/
public $debug = false;
private $version = '3.0.0';
/**
* @var string 表单 api 的秘钥
*/
private $formApiKey;
/**
* @var string rest api 和 form api 的接口地址
*/
public static $restApiEndPoint;
/**
* rest api 和 form api 接口请求地址,详见:http://docs.upyun.com/api/rest_api/
*/
const ED_AUTO = 'v0.api.upyun.com';
const ED_TELECOM = 'v1.api.upyun.com';
const ED_CNC = 'v2.api.upyun.com';
const ED_CTT = 'v3.api.upyun.com';
/**
* 分块上传接口请求地址
*/
const ED_FORM = 'm0.api.upyun.com';
/**
* 异步云处理接口地址
*/
const ED_VIDEO = 'p0.api.upyun.com';
/**
* 刷新接口地址
*/
const ED_PURGE = 'http://purge.upyun.com/purge/';
public function __construct($bucketName, $operatorName, $operatorPassword)
{
$this->bucketName = $bucketName;
$this->operatorName = $operatorName;
$this->setOperatorPassword($operatorPassword);
$this->useSsl = false;
self::$restApiEndPoint = self::ED_AUTO;
}
public function setOperatorPassword($operatorPassword)
{
$this->operatorPassword = md5($operatorPassword);
}
public function getFormApiKey()
{
if (! $this->formApiKey) {
throw new \Exception('form api key is empty.');
}
return $this->formApiKey;
}
public function setFormApiKey($key)
{
$this->formApiKey = $key;
}
public function getVersion()
{
return $this->version;
}
}