@@ -5,175 +5,175 @@ |
||
5 | 5 | /**多媒体转码的参数*/ |
6 | 6 | class MediaEncodeOption extends MediaResOption |
7 | 7 | { |
8 | - /* 以下属性是"视频转码"方法必须的属性 */ |
|
9 | - private $encodeTemplate; //模板名称。可以设置系统或者用户自定义模板。用户模板名称可以登录后台查看和设置,系统模板见附录系统模板列表 |
|
10 | - public $usePreset = 0; //是否使用系统模板。默认0。如果为1,则encodeTemplate必须设置系统模板名称 |
|
11 | - public $force = 0; //是否强制覆盖。默认0,如果为1,当output文件已经存在的时候会强制覆盖,否则不执行转码并结束任务 |
|
12 | - /* 以下属性是"视频转码"方法可选的属性 */ |
|
13 | - private $watermark; //水印资源 |
|
14 | - private $watermarkTemplate; //用户自定义水印模板 |
|
15 | - private $notifyUrl; //通知url,任务结束之后会调用这个url |
|
16 | - private $seek; //截取音视频的开始位置 |
|
17 | - private $duration; //截取音视频的长度 |
|
8 | + /* 以下属性是"视频转码"方法必须的属性 */ |
|
9 | + private $encodeTemplate; //模板名称。可以设置系统或者用户自定义模板。用户模板名称可以登录后台查看和设置,系统模板见附录系统模板列表 |
|
10 | + public $usePreset = 0; //是否使用系统模板。默认0。如果为1,则encodeTemplate必须设置系统模板名称 |
|
11 | + public $force = 0; //是否强制覆盖。默认0,如果为1,当output文件已经存在的时候会强制覆盖,否则不执行转码并结束任务 |
|
12 | + /* 以下属性是"视频转码"方法可选的属性 */ |
|
13 | + private $watermark; //水印资源 |
|
14 | + private $watermarkTemplate; //用户自定义水印模板 |
|
15 | + private $notifyUrl; //通知url,任务结束之后会调用这个url |
|
16 | + private $seek; //截取音视频的开始位置 |
|
17 | + private $duration; //截取音视频的长度 |
|
18 | 18 | |
19 | - /**设置转码模板。必须。模板在顽兔控制台"多媒体处理"中配置*/ |
|
20 | - public function setEncodeTemplate($encodeTemplate) |
|
21 | - { |
|
22 | - $this->encodeTemplate = $encodeTemplate; |
|
23 | - } |
|
24 | - /**检测多媒体转码选项是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/ |
|
25 | - public function checkOptionParameters() |
|
26 | - { |
|
27 | - list($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法 |
|
28 | - if (!$valid) { |
|
29 | - return array($valid, $msg, null); |
|
30 | - } |
|
31 | - if (empty($this->encodeTemplate)) { |
|
32 | - return array(false, "encodeTemplate is empty.", null); // 判断是否设置输入输出文件,或者转码模板 |
|
33 | - } |
|
34 | - if (($this->usePreset != 0 && $this->usePreset != 1) || ($this->force != 0 && $this->force != 1)) { |
|
35 | - return array(false, "parameters 'usePreset' or 'force' is invalid.", null); // 判断usePreset和force参数是否为0或1 |
|
36 | - } |
|
37 | - return $this->getOptionsHttpBody(); //返回http请求体 |
|
38 | - } |
|
39 | - /**构建多媒体转码所需的http请求体*/ |
|
40 | - public function getOptionsHttpBody() |
|
41 | - { |
|
42 | - //必须的参数 |
|
43 | - $httpBody = 'input=' . $this->getInputResId(); |
|
44 | - $httpBody .= '&output=' . $this->getOutputResId(); |
|
45 | - $httpBody .= '&encodeTemplate=' . urlencode($this->encodeTemplate); |
|
46 | - $httpBody .= '&usePreset=' . $this->usePreset; |
|
47 | - $httpBody .= '&force=' . $this->force; |
|
48 | - // 可选的参数 |
|
49 | - if (isset($this->watermark)) { |
|
50 | - $httpBody .= '&watermark=' . $this->watermark->buildResourceId(); |
|
51 | - } |
|
52 | - if (isset($this->watermarkTemplate)) { |
|
53 | - $httpBody .= '&watermarkTemplate=' . urlencode($this->watermarkTemplate); |
|
54 | - } |
|
55 | - if (isset($this->notifyUrl)) { |
|
56 | - $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
57 | - } |
|
58 | - if (isset($this->seek)) { |
|
59 | - $httpBody .= '&seek=' . $this->seek; |
|
60 | - } |
|
61 | - if (isset($this->duration)) { |
|
62 | - $httpBody .= '&duration=' . $this->duration; |
|
63 | - } |
|
64 | - return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体 |
|
65 | - } |
|
66 | - /*######################以下是可选的参数set方法#######################*/ |
|
67 | - /**设置水印。可选*/ |
|
68 | - public function setWatermark($namespace = null, $dir = null, $name = null) |
|
69 | - { |
|
70 | - $this->watermark = new ResourceInfo($namespace, $dir, $name); |
|
71 | - } |
|
72 | - /**设置用户自定义水印模板。可选*/ |
|
73 | - public function setWatermarkTemplate($watermarkTemplate) |
|
74 | - { |
|
75 | - $this->watermarkTemplate = $watermarkTemplate; |
|
76 | - } |
|
77 | - /**设置转码完成后的通知url。可选*/ |
|
78 | - public function setNotifyUrl($notifyUrl) |
|
79 | - { |
|
80 | - $this->notifyUrl = $notifyUrl; |
|
81 | - } |
|
82 | - /**设置转码起始位置。可选*/ |
|
83 | - public function setSeek($seek) |
|
84 | - { |
|
85 | - $this->seek = $seek; |
|
86 | - } |
|
87 | - /**设置转码长度。可选*/ |
|
88 | - public function setDuration($duration) |
|
89 | - { |
|
90 | - $this->duration = $duration; |
|
91 | - } |
|
19 | + /**设置转码模板。必须。模板在顽兔控制台"多媒体处理"中配置*/ |
|
20 | + public function setEncodeTemplate($encodeTemplate) |
|
21 | + { |
|
22 | + $this->encodeTemplate = $encodeTemplate; |
|
23 | + } |
|
24 | + /**检测多媒体转码选项是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/ |
|
25 | + public function checkOptionParameters() |
|
26 | + { |
|
27 | + list($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法 |
|
28 | + if (!$valid) { |
|
29 | + return array($valid, $msg, null); |
|
30 | + } |
|
31 | + if (empty($this->encodeTemplate)) { |
|
32 | + return array(false, "encodeTemplate is empty.", null); // 判断是否设置输入输出文件,或者转码模板 |
|
33 | + } |
|
34 | + if (($this->usePreset != 0 && $this->usePreset != 1) || ($this->force != 0 && $this->force != 1)) { |
|
35 | + return array(false, "parameters 'usePreset' or 'force' is invalid.", null); // 判断usePreset和force参数是否为0或1 |
|
36 | + } |
|
37 | + return $this->getOptionsHttpBody(); //返回http请求体 |
|
38 | + } |
|
39 | + /**构建多媒体转码所需的http请求体*/ |
|
40 | + public function getOptionsHttpBody() |
|
41 | + { |
|
42 | + //必须的参数 |
|
43 | + $httpBody = 'input=' . $this->getInputResId(); |
|
44 | + $httpBody .= '&output=' . $this->getOutputResId(); |
|
45 | + $httpBody .= '&encodeTemplate=' . urlencode($this->encodeTemplate); |
|
46 | + $httpBody .= '&usePreset=' . $this->usePreset; |
|
47 | + $httpBody .= '&force=' . $this->force; |
|
48 | + // 可选的参数 |
|
49 | + if (isset($this->watermark)) { |
|
50 | + $httpBody .= '&watermark=' . $this->watermark->buildResourceId(); |
|
51 | + } |
|
52 | + if (isset($this->watermarkTemplate)) { |
|
53 | + $httpBody .= '&watermarkTemplate=' . urlencode($this->watermarkTemplate); |
|
54 | + } |
|
55 | + if (isset($this->notifyUrl)) { |
|
56 | + $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
57 | + } |
|
58 | + if (isset($this->seek)) { |
|
59 | + $httpBody .= '&seek=' . $this->seek; |
|
60 | + } |
|
61 | + if (isset($this->duration)) { |
|
62 | + $httpBody .= '&duration=' . $this->duration; |
|
63 | + } |
|
64 | + return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体 |
|
65 | + } |
|
66 | + /*######################以下是可选的参数set方法#######################*/ |
|
67 | + /**设置水印。可选*/ |
|
68 | + public function setWatermark($namespace = null, $dir = null, $name = null) |
|
69 | + { |
|
70 | + $this->watermark = new ResourceInfo($namespace, $dir, $name); |
|
71 | + } |
|
72 | + /**设置用户自定义水印模板。可选*/ |
|
73 | + public function setWatermarkTemplate($watermarkTemplate) |
|
74 | + { |
|
75 | + $this->watermarkTemplate = $watermarkTemplate; |
|
76 | + } |
|
77 | + /**设置转码完成后的通知url。可选*/ |
|
78 | + public function setNotifyUrl($notifyUrl) |
|
79 | + { |
|
80 | + $this->notifyUrl = $notifyUrl; |
|
81 | + } |
|
82 | + /**设置转码起始位置。可选*/ |
|
83 | + public function setSeek($seek) |
|
84 | + { |
|
85 | + $this->seek = $seek; |
|
86 | + } |
|
87 | + /**设置转码长度。可选*/ |
|
88 | + public function setDuration($duration) |
|
89 | + { |
|
90 | + $this->duration = $duration; |
|
91 | + } |
|
92 | 92 | } |
93 | 93 | /**视频截图的参数*/ |
94 | 94 | class SnapShotOption extends MediaResOption |
95 | 95 | { |
96 | - /** 视频截图的位置,单位为毫秒。该属性必须*/ |
|
97 | - private $time; |
|
98 | - /** 通知url,任务结束之后会调用这个url。该属性可选 */ |
|
99 | - private $notifyUrl; |
|
100 | - /**检测视频截图参数是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/ |
|
101 | - public function checkOptionParameters() |
|
102 | - { |
|
103 | - list($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法 |
|
104 | - if (!$valid) { |
|
105 | - return array($valid, $msg, null); |
|
106 | - } |
|
107 | - if (empty($this->time) || !is_int($this->time) || $this->time < 0) { |
|
108 | - return array(false, "time is empty or invalid.", null); // 是否设置时间,且时间是否合法 |
|
109 | - } |
|
110 | - return $this->getOptionsHttpBody(); //返回http请求体 |
|
111 | - } |
|
96 | + /** 视频截图的位置,单位为毫秒。该属性必须*/ |
|
97 | + private $time; |
|
98 | + /** 通知url,任务结束之后会调用这个url。该属性可选 */ |
|
99 | + private $notifyUrl; |
|
100 | + /**检测视频截图参数是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/ |
|
101 | + public function checkOptionParameters() |
|
102 | + { |
|
103 | + list($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法 |
|
104 | + if (!$valid) { |
|
105 | + return array($valid, $msg, null); |
|
106 | + } |
|
107 | + if (empty($this->time) || !is_int($this->time) || $this->time < 0) { |
|
108 | + return array(false, "time is empty or invalid.", null); // 是否设置时间,且时间是否合法 |
|
109 | + } |
|
110 | + return $this->getOptionsHttpBody(); //返回http请求体 |
|
111 | + } |
|
112 | 112 | |
113 | - /**构建多媒体转码所需的http请求体*/ |
|
114 | - public function getOptionsHttpBody() |
|
115 | - { |
|
116 | - //必须的参数 |
|
117 | - $httpBody = 'input=' . $this->getInputResId(); |
|
118 | - $httpBody .= '&output=' . $this->getOutputResId(); |
|
119 | - $httpBody .= '&time=' . $this->time; |
|
120 | - // 可选的参数 |
|
121 | - if (isset($this->notifyUrl)) { |
|
122 | - $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
123 | - } |
|
124 | - return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体 |
|
125 | - } |
|
113 | + /**构建多媒体转码所需的http请求体*/ |
|
114 | + public function getOptionsHttpBody() |
|
115 | + { |
|
116 | + //必须的参数 |
|
117 | + $httpBody = 'input=' . $this->getInputResId(); |
|
118 | + $httpBody .= '&output=' . $this->getOutputResId(); |
|
119 | + $httpBody .= '&time=' . $this->time; |
|
120 | + // 可选的参数 |
|
121 | + if (isset($this->notifyUrl)) { |
|
122 | + $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
123 | + } |
|
124 | + return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体 |
|
125 | + } |
|
126 | 126 | |
127 | - /**设置视频截图的位置,单位为毫秒。改参数必须设置*/ |
|
128 | - public function setTime($time) |
|
129 | - { |
|
130 | - $this->time = $time; |
|
131 | - } |
|
132 | - /**设置截图完成后的通知url。可选*/ |
|
133 | - public function setNotifyUrl($notifyUrl) |
|
134 | - { |
|
135 | - $this->notifyUrl = $notifyUrl; |
|
136 | - } |
|
127 | + /**设置视频截图的位置,单位为毫秒。改参数必须设置*/ |
|
128 | + public function setTime($time) |
|
129 | + { |
|
130 | + $this->time = $time; |
|
131 | + } |
|
132 | + /**设置截图完成后的通知url。可选*/ |
|
133 | + public function setNotifyUrl($notifyUrl) |
|
134 | + { |
|
135 | + $this->notifyUrl = $notifyUrl; |
|
136 | + } |
|
137 | 137 | } |
138 | 138 | /**多媒体操作的输入输出资源信息。视频截图和视频转码都继承该类*/ |
139 | 139 | abstract class MediaResOption |
140 | 140 | { |
141 | - private $input; //输入的资源 |
|
142 | - private $output; //输出的资源 |
|
143 | - /**设置输入的文件。*/ |
|
144 | - public function setInputResource($namespace = null, $dir = null, $name = null) |
|
145 | - { |
|
146 | - $this->input = new ResourceInfo($namespace, $dir, $name); |
|
147 | - } |
|
148 | - /**设置输出的文件。*/ |
|
149 | - public function setOutputResource($namespace = null, $dir = null, $name = null) |
|
150 | - { |
|
151 | - $this->output = new ResourceInfo($namespace, $dir, $name); |
|
152 | - } |
|
153 | - /**检测参数选项是否合法*/ |
|
154 | - public function checkOptionParameters() |
|
155 | - { |
|
156 | - if (empty($this->input) || empty($this->output)) { |
|
157 | - return array(false, "input or output resources is empty."); // 判断是否设置输入输出文件,或者转码模板 |
|
158 | - } |
|
159 | - list($valid, $msg) = $this->input->checkResourceInfo(true, true); //检测输入的资源信息是否合法 |
|
160 | - if (!$valid) { |
|
161 | - return array($valid, $msg); |
|
162 | - } |
|
163 | - list($valid, $msg) = $this->output->checkResourceInfo(true, true); //检测输入的资源信息是否合法 |
|
164 | - if (!$valid) { |
|
165 | - return array($valid, $msg); |
|
166 | - } |
|
167 | - return array(true, null); |
|
168 | - } |
|
169 | - public function getInputResId() |
|
170 | - { |
|
171 | - return $this->input->buildResourceId(); |
|
172 | - } |
|
173 | - public function getOutputResId() |
|
174 | - { |
|
175 | - return $this->output->buildResourceId(); |
|
176 | - } |
|
177 | - /**得到属性的http请求体*/ |
|
178 | - abstract public function getOptionsHttpBody(); |
|
141 | + private $input; //输入的资源 |
|
142 | + private $output; //输出的资源 |
|
143 | + /**设置输入的文件。*/ |
|
144 | + public function setInputResource($namespace = null, $dir = null, $name = null) |
|
145 | + { |
|
146 | + $this->input = new ResourceInfo($namespace, $dir, $name); |
|
147 | + } |
|
148 | + /**设置输出的文件。*/ |
|
149 | + public function setOutputResource($namespace = null, $dir = null, $name = null) |
|
150 | + { |
|
151 | + $this->output = new ResourceInfo($namespace, $dir, $name); |
|
152 | + } |
|
153 | + /**检测参数选项是否合法*/ |
|
154 | + public function checkOptionParameters() |
|
155 | + { |
|
156 | + if (empty($this->input) || empty($this->output)) { |
|
157 | + return array(false, "input or output resources is empty."); // 判断是否设置输入输出文件,或者转码模板 |
|
158 | + } |
|
159 | + list($valid, $msg) = $this->input->checkResourceInfo(true, true); //检测输入的资源信息是否合法 |
|
160 | + if (!$valid) { |
|
161 | + return array($valid, $msg); |
|
162 | + } |
|
163 | + list($valid, $msg) = $this->output->checkResourceInfo(true, true); //检测输入的资源信息是否合法 |
|
164 | + if (!$valid) { |
|
165 | + return array($valid, $msg); |
|
166 | + } |
|
167 | + return array(true, null); |
|
168 | + } |
|
169 | + public function getInputResId() |
|
170 | + { |
|
171 | + return $this->input->buildResourceId(); |
|
172 | + } |
|
173 | + public function getOutputResId() |
|
174 | + { |
|
175 | + return $this->output->buildResourceId(); |
|
176 | + } |
|
177 | + /**得到属性的http请求体*/ |
|
178 | + abstract public function getOptionsHttpBody(); |
|
179 | 179 | } |
@@ -6,15 +6,15 @@ discard block |
||
6 | 6 | class MediaEncodeOption extends MediaResOption |
7 | 7 | { |
8 | 8 | /* 以下属性是"视频转码"方法必须的属性 */ |
9 | - private $encodeTemplate; //模板名称。可以设置系统或者用户自定义模板。用户模板名称可以登录后台查看和设置,系统模板见附录系统模板列表 |
|
10 | - public $usePreset = 0; //是否使用系统模板。默认0。如果为1,则encodeTemplate必须设置系统模板名称 |
|
11 | - public $force = 0; //是否强制覆盖。默认0,如果为1,当output文件已经存在的时候会强制覆盖,否则不执行转码并结束任务 |
|
9 | + private $encodeTemplate; //模板名称。可以设置系统或者用户自定义模板。用户模板名称可以登录后台查看和设置,系统模板见附录系统模板列表 |
|
10 | + public $usePreset = 0; //是否使用系统模板。默认0。如果为1,则encodeTemplate必须设置系统模板名称 |
|
11 | + public $force = 0; //是否强制覆盖。默认0,如果为1,当output文件已经存在的时候会强制覆盖,否则不执行转码并结束任务 |
|
12 | 12 | /* 以下属性是"视频转码"方法可选的属性 */ |
13 | - private $watermark; //水印资源 |
|
14 | - private $watermarkTemplate; //用户自定义水印模板 |
|
15 | - private $notifyUrl; //通知url,任务结束之后会调用这个url |
|
16 | - private $seek; //截取音视频的开始位置 |
|
17 | - private $duration; //截取音视频的长度 |
|
13 | + private $watermark; //水印资源 |
|
14 | + private $watermarkTemplate; //用户自定义水印模板 |
|
15 | + private $notifyUrl; //通知url,任务结束之后会调用这个url |
|
16 | + private $seek; //截取音视频的开始位置 |
|
17 | + private $duration; //截取音视频的长度 |
|
18 | 18 | |
19 | 19 | /**设置转码模板。必须。模板在顽兔控制台"多媒体处理"中配置*/ |
20 | 20 | public function setEncodeTemplate($encodeTemplate) |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
57 | 57 | } |
58 | 58 | if (isset($this->seek)) { |
59 | - $httpBody .= '&seek=' . $this->seek; |
|
59 | + $httpBody .= '&seek=' . $this->seek; |
|
60 | 60 | } |
61 | 61 | if (isset($this->duration)) { |
62 | 62 | $httpBody .= '&duration=' . $this->duration; |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | /**多媒体操作的输入输出资源信息。视频截图和视频转码都继承该类*/ |
139 | 139 | abstract class MediaResOption |
140 | 140 | { |
141 | - private $input; //输入的资源 |
|
142 | - private $output; //输出的资源 |
|
141 | + private $input; //输入的资源 |
|
142 | + private $output; //输出的资源 |
|
143 | 143 | /**设置输入的文件。*/ |
144 | 144 | public function setInputResource($namespace = null, $dir = null, $name = null) |
145 | 145 | { |
@@ -6,166 +6,166 @@ discard block |
||
6 | 6 | |
7 | 7 | class UploadOption |
8 | 8 | { |
9 | - /*optionType用于标识UploadOption的类型,即:普通上传、初始化分片上传、分片上传、分片上传完成*/ |
|
10 | - public $optionType; |
|
9 | + /*optionType用于标识UploadOption的类型,即:普通上传、初始化分片上传、分片上传、分片上传完成*/ |
|
10 | + public $optionType; |
|
11 | 11 | |
12 | - /*以下属性是上传时的可选参数。即Rest API中Http请求Body中所需的可选参数*/ |
|
13 | - public $dir; // 顽兔空间的图片路径(如果UploadPolicy中不指定dir属性,则生效) |
|
14 | - public $name; // 上传到服务端的文件名(如果UploadPolicy中不指定name属性,则生效) |
|
15 | - public $metaArray; // 用户自定义的文件meta信息("meta-"为参数前缀, "*"为用户用于渲染的自定义Meta信息名) |
|
16 | - public $varArray; // 用户自定义的魔法变量("var-"为参数前缀, "*"为用户用于渲染的自定义魔法变量名) |
|
17 | - private $md5; // 文件md5值(推荐提供此参数进行一致性检查) |
|
18 | - private $size; // 文件大小 |
|
19 | - private $content; // 文件内容(在http请求体Body中必须位于参数的最后一位) |
|
12 | + /*以下属性是上传时的可选参数。即Rest API中Http请求Body中所需的可选参数*/ |
|
13 | + public $dir; // 顽兔空间的图片路径(如果UploadPolicy中不指定dir属性,则生效) |
|
14 | + public $name; // 上传到服务端的文件名(如果UploadPolicy中不指定name属性,则生效) |
|
15 | + public $metaArray; // 用户自定义的文件meta信息("meta-"为参数前缀, "*"为用户用于渲染的自定义Meta信息名) |
|
16 | + public $varArray; // 用户自定义的魔法变量("var-"为参数前缀, "*"为用户用于渲染的自定义魔法变量名) |
|
17 | + private $md5; // 文件md5值(推荐提供此参数进行一致性检查) |
|
18 | + private $size; // 文件大小 |
|
19 | + private $content; // 文件内容(在http请求体Body中必须位于参数的最后一位) |
|
20 | 20 | |
21 | - /*以下属性是用户根据自己应用需求,可选的配置*/ |
|
22 | - public $blockSize; // 文件分片的大小。针对分片上传。 |
|
23 | - public $timeout; // 进行http连接的超时时间 |
|
24 | - public $httpReTry; // http失败自动重试。0 or 1 |
|
21 | + /*以下属性是用户根据自己应用需求,可选的配置*/ |
|
22 | + public $blockSize; // 文件分片的大小。针对分片上传。 |
|
23 | + public $timeout; // 进行http连接的超时时间 |
|
24 | + public $httpReTry; // http失败自动重试。0 or 1 |
|
25 | 25 | |
26 | - /*以下属性是用于分片上传时的参数,仅用于分片上传。用户在调用分片上传时可以选择配置。*/ |
|
27 | - private $uploadId; // OSS分片上传ID(OSS用于区分上传的id) |
|
28 | - private $uniqueId; // 服务上传唯一ID(多媒体服务用于区分上传的id) |
|
29 | - private $partNumber; // 分片文件块上传成功后返回的文件块编号 |
|
30 | - private $eTag; // 分片文件块上传成功后返回的Tag标签(由md5和其他标记组成) |
|
31 | - private $array_PartNum_ETag; // 分片上传服务端返回的所有 块编号partNumber 和 标记ETag |
|
26 | + /*以下属性是用于分片上传时的参数,仅用于分片上传。用户在调用分片上传时可以选择配置。*/ |
|
27 | + private $uploadId; // OSS分片上传ID(OSS用于区分上传的id) |
|
28 | + private $uniqueId; // 服务上传唯一ID(多媒体服务用于区分上传的id) |
|
29 | + private $partNumber; // 分片文件块上传成功后返回的文件块编号 |
|
30 | + private $eTag; // 分片文件块上传成功后返回的Tag标签(由md5和其他标记组成) |
|
31 | + private $array_PartNum_ETag; // 分片上传服务端返回的所有 块编号partNumber 和 标记ETag |
|
32 | 32 | |
33 | - public function __construct() |
|
34 | - { |
|
35 | - $this->optionType = UpOptionType::COMMON_UPLOAD_TYPE; //默认普通上传类型 |
|
36 | - $this->metaArray = array(); |
|
37 | - $this->varArray = array(); |
|
38 | - $this->blockSize = Conf::BLOCK_DEFF_SIZE; //默认2M |
|
39 | - $this->timeout = Conf::HTTP_TIMEOUT; //默认超时30s |
|
40 | - $this->httpReTry = Conf::HTTP_RETRY; //默认重试 |
|
41 | - $this->array_PartNum_ETag = array(); |
|
42 | - } |
|
43 | - /**得到上传时http请求体所需的参数*/ |
|
44 | - public function getParaArray() |
|
45 | - { |
|
46 | - switch ($this->optionType) { |
|
47 | - case UpOptionType::COMMON_UPLOAD_TYPE: |
|
48 | - case UpOptionType::BLOCK_INIT_UPLOAD: |
|
49 | - return $this->getParas_Common_BlockInit(); |
|
50 | - case UpOptionType::BLOCK_RUN_UPLOAD: |
|
51 | - return $this->getParas_BlockRun(); |
|
52 | - case UpOptionType::BLOCK_COMPLETE_UPLOAD: |
|
53 | - return $this->getParas_BlockComplete(); |
|
54 | - case UpOptionType::BLOCK_CANCEL_UPLOAD: |
|
55 | - return $this->getParas_BlockCancel(); |
|
56 | - default: |
|
57 | - return null; |
|
58 | - } |
|
59 | - } |
|
60 | - /** 构造 普通上传 或者 初始化分片上传 所需的参数 */ |
|
61 | - private function getParas_Common_BlockInit() |
|
62 | - { |
|
63 | - $paraArray = array(); |
|
64 | - if (isset($this->dir)) { |
|
65 | - $paraArray['dir'] = $this->dir; |
|
66 | - } |
|
67 | - if (isset($this->name)) { |
|
68 | - $paraArray['name'] = $this->name; |
|
69 | - } |
|
70 | - $paraArray['md5'] = md5($this->content); // 计算文件md5 |
|
71 | - $paraArray['size'] = strlen($this->content); // 计算文件大小 |
|
72 | - $paraArray['content'] = $this->content; |
|
73 | - $this->createMetaVars($paraArray, "meta", $this->metaArray); |
|
74 | - $this->createMetaVars($paraArray, "var", $this->varArray); |
|
75 | - return $paraArray; |
|
76 | - } |
|
77 | - /** 构造 分片上传过程中 所需的参数 */ |
|
78 | - private function getParas_BlockRun() |
|
79 | - { |
|
80 | - $paraArray = array(); |
|
81 | - $paraArray['uploadId'] = $this->uploadId; |
|
82 | - $paraArray['id'] = $this->uniqueId; |
|
83 | - $paraArray['partNumber'] = $this->partNumber; |
|
84 | - $paraArray['md5'] = md5($this->content); // 计算文件md5 |
|
85 | - $paraArray['size'] = strlen($this->content); // 计算文件大小 |
|
86 | - $paraArray['content'] = $this->content; |
|
87 | - return $paraArray; |
|
88 | - } |
|
89 | - /** 构造 分片上传完成时 所需的参数 */ |
|
90 | - private function getParas_BlockComplete() |
|
91 | - { |
|
92 | - $paraArray = array(); |
|
93 | - $paraArray['uploadId'] = $this->uploadId; |
|
94 | - $paraArray['id'] = $this->uniqueId; |
|
95 | - $paraArray['md5'] = $this->md5; |
|
96 | - $parts = EncodeUtils::encodeWithURLSafeBase64(json_encode($this->array_PartNum_ETag)); |
|
97 | - $paraArray['parts'] = $parts; // 所有文件块的编号partNumber 和 标记ETag,需要进行base64的编码 |
|
98 | - return $paraArray; |
|
99 | - } |
|
100 | - /** 构造 分片上传取消 所需的参数 */ |
|
101 | - private function getParas_BlockCancel() |
|
102 | - { |
|
103 | - return array('id' => $this->uniqueId, 'uploadId' => $this->uploadId); |
|
104 | - } |
|
105 | - /** |
|
106 | - * 构建上传http请求体的meta-*和var-*选项参数。将tempArr中的元素加上前缀prefix,然后保存到paraArr中 |
|
107 | - * @param array $paraArr 最终的数组 |
|
108 | - * @param string $prefix 前缀 |
|
109 | - * @param array $tempArr 待添加的数组 |
|
110 | - * @return array $paraArr 最终的数组 |
|
111 | - */ |
|
112 | - private function createMetaVars($paraArr, $prefix, $tempArr) |
|
113 | - { |
|
114 | - foreach ($tempArr as $key => $val) { |
|
115 | - $key = $prefix . '-' . $key; |
|
116 | - $paraArr[$key] = $val; |
|
117 | - } |
|
118 | - return $paraArr; |
|
119 | - } |
|
120 | - /**设置待上传的数据。该方法开发者不需要调用,该方法根据用户数据自动调用 |
|
33 | + public function __construct() |
|
34 | + { |
|
35 | + $this->optionType = UpOptionType::COMMON_UPLOAD_TYPE; //默认普通上传类型 |
|
36 | + $this->metaArray = array(); |
|
37 | + $this->varArray = array(); |
|
38 | + $this->blockSize = Conf::BLOCK_DEFF_SIZE; //默认2M |
|
39 | + $this->timeout = Conf::HTTP_TIMEOUT; //默认超时30s |
|
40 | + $this->httpReTry = Conf::HTTP_RETRY; //默认重试 |
|
41 | + $this->array_PartNum_ETag = array(); |
|
42 | + } |
|
43 | + /**得到上传时http请求体所需的参数*/ |
|
44 | + public function getParaArray() |
|
45 | + { |
|
46 | + switch ($this->optionType) { |
|
47 | + case UpOptionType::COMMON_UPLOAD_TYPE: |
|
48 | + case UpOptionType::BLOCK_INIT_UPLOAD: |
|
49 | + return $this->getParas_Common_BlockInit(); |
|
50 | + case UpOptionType::BLOCK_RUN_UPLOAD: |
|
51 | + return $this->getParas_BlockRun(); |
|
52 | + case UpOptionType::BLOCK_COMPLETE_UPLOAD: |
|
53 | + return $this->getParas_BlockComplete(); |
|
54 | + case UpOptionType::BLOCK_CANCEL_UPLOAD: |
|
55 | + return $this->getParas_BlockCancel(); |
|
56 | + default: |
|
57 | + return null; |
|
58 | + } |
|
59 | + } |
|
60 | + /** 构造 普通上传 或者 初始化分片上传 所需的参数 */ |
|
61 | + private function getParas_Common_BlockInit() |
|
62 | + { |
|
63 | + $paraArray = array(); |
|
64 | + if (isset($this->dir)) { |
|
65 | + $paraArray['dir'] = $this->dir; |
|
66 | + } |
|
67 | + if (isset($this->name)) { |
|
68 | + $paraArray['name'] = $this->name; |
|
69 | + } |
|
70 | + $paraArray['md5'] = md5($this->content); // 计算文件md5 |
|
71 | + $paraArray['size'] = strlen($this->content); // 计算文件大小 |
|
72 | + $paraArray['content'] = $this->content; |
|
73 | + $this->createMetaVars($paraArray, "meta", $this->metaArray); |
|
74 | + $this->createMetaVars($paraArray, "var", $this->varArray); |
|
75 | + return $paraArray; |
|
76 | + } |
|
77 | + /** 构造 分片上传过程中 所需的参数 */ |
|
78 | + private function getParas_BlockRun() |
|
79 | + { |
|
80 | + $paraArray = array(); |
|
81 | + $paraArray['uploadId'] = $this->uploadId; |
|
82 | + $paraArray['id'] = $this->uniqueId; |
|
83 | + $paraArray['partNumber'] = $this->partNumber; |
|
84 | + $paraArray['md5'] = md5($this->content); // 计算文件md5 |
|
85 | + $paraArray['size'] = strlen($this->content); // 计算文件大小 |
|
86 | + $paraArray['content'] = $this->content; |
|
87 | + return $paraArray; |
|
88 | + } |
|
89 | + /** 构造 分片上传完成时 所需的参数 */ |
|
90 | + private function getParas_BlockComplete() |
|
91 | + { |
|
92 | + $paraArray = array(); |
|
93 | + $paraArray['uploadId'] = $this->uploadId; |
|
94 | + $paraArray['id'] = $this->uniqueId; |
|
95 | + $paraArray['md5'] = $this->md5; |
|
96 | + $parts = EncodeUtils::encodeWithURLSafeBase64(json_encode($this->array_PartNum_ETag)); |
|
97 | + $paraArray['parts'] = $parts; // 所有文件块的编号partNumber 和 标记ETag,需要进行base64的编码 |
|
98 | + return $paraArray; |
|
99 | + } |
|
100 | + /** 构造 分片上传取消 所需的参数 */ |
|
101 | + private function getParas_BlockCancel() |
|
102 | + { |
|
103 | + return array('id' => $this->uniqueId, 'uploadId' => $this->uploadId); |
|
104 | + } |
|
105 | + /** |
|
106 | + * 构建上传http请求体的meta-*和var-*选项参数。将tempArr中的元素加上前缀prefix,然后保存到paraArr中 |
|
107 | + * @param array $paraArr 最终的数组 |
|
108 | + * @param string $prefix 前缀 |
|
109 | + * @param array $tempArr 待添加的数组 |
|
110 | + * @return array $paraArr 最终的数组 |
|
111 | + */ |
|
112 | + private function createMetaVars($paraArr, $prefix, $tempArr) |
|
113 | + { |
|
114 | + foreach ($tempArr as $key => $val) { |
|
115 | + $key = $prefix . '-' . $key; |
|
116 | + $paraArr[$key] = $val; |
|
117 | + } |
|
118 | + return $paraArr; |
|
119 | + } |
|
120 | + /**设置待上传的数据。该方法开发者不需要调用,该方法根据用户数据自动调用 |
|
121 | 121 | * @param string $data 字符串 */ |
122 | - public function setContent($data) |
|
123 | - { |
|
124 | - $this->content = $data; |
|
125 | - } |
|
126 | - /**设置MD5值。该方法主要用于在分片上传完成时调用 |
|
122 | + public function setContent($data) |
|
123 | + { |
|
124 | + $this->content = $data; |
|
125 | + } |
|
126 | + /**设置MD5值。该方法主要用于在分片上传完成时调用 |
|
127 | 127 | * @param string $value md5值 */ |
128 | - public function setMd5($value) |
|
129 | - { |
|
130 | - $this->md5 = $value; |
|
131 | - } |
|
132 | - /**得到MD5值。该方法主要用于在分片上传完成时调用*/ |
|
133 | - public function getMd5() |
|
134 | - { |
|
135 | - return $this->md5; |
|
136 | - } |
|
137 | - /*下面四个函数均是用于分片上传时的设置,开发者不需要调用*/ |
|
138 | - /**分片上传时用于设置uploadId */ |
|
139 | - public function setUploadId($uploadId) |
|
140 | - { |
|
141 | - $this->uploadId = $uploadId; |
|
142 | - } |
|
143 | - /**分片上传时用于设置id */ |
|
144 | - public function setUniqueIdId($id) |
|
145 | - { |
|
146 | - $this->uniqueId = $id; |
|
147 | - } |
|
148 | - /**分片上传时,用于获取分片上传时的块编号partNumber */ |
|
149 | - public function getPartNumber() |
|
150 | - { |
|
151 | - return $this->partNumber; |
|
152 | - } |
|
153 | - /**分片上传时,用于设置分片上传时的块编号partNumber */ |
|
154 | - public function setPartNumber($partNumber) |
|
155 | - { |
|
156 | - $this->partNumber = $partNumber; |
|
157 | - } |
|
158 | - /**分片上传过程中,用于保存所有的 块编号partNumber 和 标记ETag*/ |
|
159 | - public function addPartNumberAndETag($partNumber, $eTag) |
|
160 | - { |
|
161 | - $this->eTag = $eTag; |
|
162 | - array_push($this->array_PartNum_ETag, array("partNumber" => $partNumber, "eTag" => $eTag)); |
|
163 | - } |
|
164 | - /**检测分片上传的参数。即uploadId、uniqueId是否有值*/ |
|
165 | - public function checkMutipartParas() |
|
166 | - { |
|
167 | - return isset($this->uploadId) && isset($this->uniqueId); |
|
168 | - } |
|
128 | + public function setMd5($value) |
|
129 | + { |
|
130 | + $this->md5 = $value; |
|
131 | + } |
|
132 | + /**得到MD5值。该方法主要用于在分片上传完成时调用*/ |
|
133 | + public function getMd5() |
|
134 | + { |
|
135 | + return $this->md5; |
|
136 | + } |
|
137 | + /*下面四个函数均是用于分片上传时的设置,开发者不需要调用*/ |
|
138 | + /**分片上传时用于设置uploadId */ |
|
139 | + public function setUploadId($uploadId) |
|
140 | + { |
|
141 | + $this->uploadId = $uploadId; |
|
142 | + } |
|
143 | + /**分片上传时用于设置id */ |
|
144 | + public function setUniqueIdId($id) |
|
145 | + { |
|
146 | + $this->uniqueId = $id; |
|
147 | + } |
|
148 | + /**分片上传时,用于获取分片上传时的块编号partNumber */ |
|
149 | + public function getPartNumber() |
|
150 | + { |
|
151 | + return $this->partNumber; |
|
152 | + } |
|
153 | + /**分片上传时,用于设置分片上传时的块编号partNumber */ |
|
154 | + public function setPartNumber($partNumber) |
|
155 | + { |
|
156 | + $this->partNumber = $partNumber; |
|
157 | + } |
|
158 | + /**分片上传过程中,用于保存所有的 块编号partNumber 和 标记ETag*/ |
|
159 | + public function addPartNumberAndETag($partNumber, $eTag) |
|
160 | + { |
|
161 | + $this->eTag = $eTag; |
|
162 | + array_push($this->array_PartNum_ETag, array("partNumber" => $partNumber, "eTag" => $eTag)); |
|
163 | + } |
|
164 | + /**检测分片上传的参数。即uploadId、uniqueId是否有值*/ |
|
165 | + public function checkMutipartParas() |
|
166 | + { |
|
167 | + return isset($this->uploadId) && isset($this->uniqueId); |
|
168 | + } |
|
169 | 169 | } |
170 | 170 | /** |
171 | 171 | * 用于标识UploadOption对象的类型 |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | */ |
174 | 174 | class UpOptionType |
175 | 175 | { |
176 | - //下面的常量用于标识UploadOption对象适用的类型 |
|
177 | - const COMMON_UPLOAD_TYPE = 0; //普通上传时的UploadOption类型 |
|
178 | - const BLOCK_INIT_UPLOAD = 1; //分片初始化时的UploadOption类型 |
|
179 | - const BLOCK_RUN_UPLOAD = 2; //分片上传过程中的UploadOption类型 |
|
180 | - const BLOCK_COMPLETE_UPLOAD = 3; //分片上传完成时的UploadOption类型 |
|
181 | - const BLOCK_CANCEL_UPLOAD = 4; //分片上传取消时的UploadOption类型 |
|
176 | + //下面的常量用于标识UploadOption对象适用的类型 |
|
177 | + const COMMON_UPLOAD_TYPE = 0; //普通上传时的UploadOption类型 |
|
178 | + const BLOCK_INIT_UPLOAD = 1; //分片初始化时的UploadOption类型 |
|
179 | + const BLOCK_RUN_UPLOAD = 2; //分片上传过程中的UploadOption类型 |
|
180 | + const BLOCK_COMPLETE_UPLOAD = 3; //分片上传完成时的UploadOption类型 |
|
181 | + const BLOCK_CANCEL_UPLOAD = 4; //分片上传取消时的UploadOption类型 |
|
182 | 182 | } |
@@ -10,34 +10,34 @@ discard block |
||
10 | 10 | public $optionType; |
11 | 11 | |
12 | 12 | /*以下属性是上传时的可选参数。即Rest API中Http请求Body中所需的可选参数*/ |
13 | - public $dir; // 顽兔空间的图片路径(如果UploadPolicy中不指定dir属性,则生效) |
|
14 | - public $name; // 上传到服务端的文件名(如果UploadPolicy中不指定name属性,则生效) |
|
15 | - public $metaArray; // 用户自定义的文件meta信息("meta-"为参数前缀, "*"为用户用于渲染的自定义Meta信息名) |
|
16 | - public $varArray; // 用户自定义的魔法变量("var-"为参数前缀, "*"为用户用于渲染的自定义魔法变量名) |
|
17 | - private $md5; // 文件md5值(推荐提供此参数进行一致性检查) |
|
18 | - private $size; // 文件大小 |
|
19 | - private $content; // 文件内容(在http请求体Body中必须位于参数的最后一位) |
|
13 | + public $dir; // 顽兔空间的图片路径(如果UploadPolicy中不指定dir属性,则生效) |
|
14 | + public $name; // 上传到服务端的文件名(如果UploadPolicy中不指定name属性,则生效) |
|
15 | + public $metaArray; // 用户自定义的文件meta信息("meta-"为参数前缀, "*"为用户用于渲染的自定义Meta信息名) |
|
16 | + public $varArray; // 用户自定义的魔法变量("var-"为参数前缀, "*"为用户用于渲染的自定义魔法变量名) |
|
17 | + private $md5; // 文件md5值(推荐提供此参数进行一致性检查) |
|
18 | + private $size; // 文件大小 |
|
19 | + private $content; // 文件内容(在http请求体Body中必须位于参数的最后一位) |
|
20 | 20 | |
21 | 21 | /*以下属性是用户根据自己应用需求,可选的配置*/ |
22 | - public $blockSize; // 文件分片的大小。针对分片上传。 |
|
23 | - public $timeout; // 进行http连接的超时时间 |
|
24 | - public $httpReTry; // http失败自动重试。0 or 1 |
|
22 | + public $blockSize; // 文件分片的大小。针对分片上传。 |
|
23 | + public $timeout; // 进行http连接的超时时间 |
|
24 | + public $httpReTry; // http失败自动重试。0 or 1 |
|
25 | 25 | |
26 | 26 | /*以下属性是用于分片上传时的参数,仅用于分片上传。用户在调用分片上传时可以选择配置。*/ |
27 | - private $uploadId; // OSS分片上传ID(OSS用于区分上传的id) |
|
28 | - private $uniqueId; // 服务上传唯一ID(多媒体服务用于区分上传的id) |
|
29 | - private $partNumber; // 分片文件块上传成功后返回的文件块编号 |
|
30 | - private $eTag; // 分片文件块上传成功后返回的Tag标签(由md5和其他标记组成) |
|
31 | - private $array_PartNum_ETag; // 分片上传服务端返回的所有 块编号partNumber 和 标记ETag |
|
27 | + private $uploadId; // OSS分片上传ID(OSS用于区分上传的id) |
|
28 | + private $uniqueId; // 服务上传唯一ID(多媒体服务用于区分上传的id) |
|
29 | + private $partNumber; // 分片文件块上传成功后返回的文件块编号 |
|
30 | + private $eTag; // 分片文件块上传成功后返回的Tag标签(由md5和其他标记组成) |
|
31 | + private $array_PartNum_ETag; // 分片上传服务端返回的所有 块编号partNumber 和 标记ETag |
|
32 | 32 | |
33 | 33 | public function __construct() |
34 | 34 | { |
35 | 35 | $this->optionType = UpOptionType::COMMON_UPLOAD_TYPE; //默认普通上传类型 |
36 | 36 | $this->metaArray = array(); |
37 | 37 | $this->varArray = array(); |
38 | - $this->blockSize = Conf::BLOCK_DEFF_SIZE; //默认2M |
|
39 | - $this->timeout = Conf::HTTP_TIMEOUT; //默认超时30s |
|
40 | - $this->httpReTry = Conf::HTTP_RETRY; //默认重试 |
|
38 | + $this->blockSize = Conf::BLOCK_DEFF_SIZE; //默认2M |
|
39 | + $this->timeout = Conf::HTTP_TIMEOUT; //默认超时30s |
|
40 | + $this->httpReTry = Conf::HTTP_RETRY; //默认重试 |
|
41 | 41 | $this->array_PartNum_ETag = array(); |
42 | 42 | } |
43 | 43 | /**得到上传时http请求体所需的参数*/ |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | class UpOptionType |
175 | 175 | { |
176 | 176 | //下面的常量用于标识UploadOption对象适用的类型 |
177 | - const COMMON_UPLOAD_TYPE = 0; //普通上传时的UploadOption类型 |
|
178 | - const BLOCK_INIT_UPLOAD = 1; //分片初始化时的UploadOption类型 |
|
179 | - const BLOCK_RUN_UPLOAD = 2; //分片上传过程中的UploadOption类型 |
|
180 | - const BLOCK_COMPLETE_UPLOAD = 3; //分片上传完成时的UploadOption类型 |
|
181 | - const BLOCK_CANCEL_UPLOAD = 4; //分片上传取消时的UploadOption类型 |
|
177 | + const COMMON_UPLOAD_TYPE = 0; //普通上传时的UploadOption类型 |
|
178 | + const BLOCK_INIT_UPLOAD = 1; //分片初始化时的UploadOption类型 |
|
179 | + const BLOCK_RUN_UPLOAD = 2; //分片上传过程中的UploadOption类型 |
|
180 | + const BLOCK_COMPLETE_UPLOAD = 3; //分片上传完成时的UploadOption类型 |
|
181 | + const BLOCK_CANCEL_UPLOAD = 4; //分片上传取消时的UploadOption类型 |
|
182 | 182 | } |
@@ -5,47 +5,47 @@ |
||
5 | 5 | |
6 | 6 | class UploadPolicy |
7 | 7 | { |
8 | - /*如下属性是必须的[The following attributes are required]*/ |
|
9 | - public $namespace; // 多媒体服务的空间名[media namespace name] |
|
10 | - public $bucket; // OSS的空间名[media bucket name] |
|
11 | - public $insertOnly; // 是否可覆盖[upload mode. it's not allowd uploading the same name files] |
|
12 | - public $expiration; // 过期时间[expiration time, unix time, in milliseconds] |
|
8 | + /*如下属性是必须的[The following attributes are required]*/ |
|
9 | + public $namespace; // 多媒体服务的空间名[media namespace name] |
|
10 | + public $bucket; // OSS的空间名[media bucket name] |
|
11 | + public $insertOnly; // 是否可覆盖[upload mode. it's not allowd uploading the same name files] |
|
12 | + public $expiration; // 过期时间[expiration time, unix time, in milliseconds] |
|
13 | 13 | |
14 | - /*如下属性是可选的[The following attributes are optional]*/ |
|
15 | - public $detectMime = Conf::DETECT_MIME_TRUE; // 是否进行类型检测[is auto detecte media file mime type, default is true] |
|
16 | - public $dir; // 路径[media file dir, magic vars and custom vars are supported] |
|
17 | - public $name; // 上传到服务端的文件名[media file name, magic vars and custom vars are supported] |
|
18 | - public $sizeLimit; // 文件大小限制[upload size limited, in bytes] |
|
19 | - public $mimeLimit; // 文件类型限制[upload mime type limited] |
|
20 | - public $callbackUrl; // 回调URL [callback urls, ip address is recommended] |
|
21 | - public $callbackHost; // 回调时Host [callback host] |
|
22 | - public $callbackBody; // 回调时Body [callback body, magic vars and custom vars are supported] |
|
23 | - public $callbackBodyType; // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8'] |
|
24 | - public $returnUrl; // 上传完成之后,303跳转的Url [return url, when return code is 303] |
|
25 | - public $returnBody; // 上传完成返回体 [return body, magic vars and custom vars are supported] |
|
26 | - public $mediaEncode; // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string] |
|
14 | + /*如下属性是可选的[The following attributes are optional]*/ |
|
15 | + public $detectMime = Conf::DETECT_MIME_TRUE; // 是否进行类型检测[is auto detecte media file mime type, default is true] |
|
16 | + public $dir; // 路径[media file dir, magic vars and custom vars are supported] |
|
17 | + public $name; // 上传到服务端的文件名[media file name, magic vars and custom vars are supported] |
|
18 | + public $sizeLimit; // 文件大小限制[upload size limited, in bytes] |
|
19 | + public $mimeLimit; // 文件类型限制[upload mime type limited] |
|
20 | + public $callbackUrl; // 回调URL [callback urls, ip address is recommended] |
|
21 | + public $callbackHost; // 回调时Host [callback host] |
|
22 | + public $callbackBody; // 回调时Body [callback body, magic vars and custom vars are supported] |
|
23 | + public $callbackBodyType; // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8'] |
|
24 | + public $returnUrl; // 上传完成之后,303跳转的Url [return url, when return code is 303] |
|
25 | + public $returnBody; // 上传完成返回体 [return body, magic vars and custom vars are supported] |
|
26 | + public $mediaEncode; // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string] |
|
27 | 27 | |
28 | - public function __construct($option) |
|
29 | - { |
|
30 | - if (!isset($option['expiration']) || !$option['expiration']) { |
|
31 | - $option['expiration'] = -1; |
|
32 | - } |
|
28 | + public function __construct($option) |
|
29 | + { |
|
30 | + if (!isset($option['expiration']) || !$option['expiration']) { |
|
31 | + $option['expiration'] = -1; |
|
32 | + } |
|
33 | 33 | |
34 | - foreach ($option as $attribute => $value) { |
|
35 | - $this->{$attribute} = $value; |
|
36 | - } |
|
37 | - } |
|
34 | + foreach ($option as $attribute => $value) { |
|
35 | + $this->{$attribute} = $value; |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - public function toArray() |
|
40 | - { |
|
41 | - return (array) $this; |
|
42 | - $array = []; |
|
43 | - foreach ($this as $attribute => $value) { |
|
44 | - if ($value !== null) { |
|
45 | - $array[$attribute] = $value; |
|
46 | - } |
|
47 | - } |
|
39 | + public function toArray() |
|
40 | + { |
|
41 | + return (array) $this; |
|
42 | + $array = []; |
|
43 | + foreach ($this as $attribute => $value) { |
|
44 | + if ($value !== null) { |
|
45 | + $array[$attribute] = $value; |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - return $array; |
|
50 | - } |
|
49 | + return $array; |
|
50 | + } |
|
51 | 51 | } |
@@ -6,24 +6,24 @@ |
||
6 | 6 | class UploadPolicy |
7 | 7 | { |
8 | 8 | /*如下属性是必须的[The following attributes are required]*/ |
9 | - public $namespace; // 多媒体服务的空间名[media namespace name] |
|
10 | - public $bucket; // OSS的空间名[media bucket name] |
|
11 | - public $insertOnly; // 是否可覆盖[upload mode. it's not allowd uploading the same name files] |
|
12 | - public $expiration; // 过期时间[expiration time, unix time, in milliseconds] |
|
9 | + public $namespace; // 多媒体服务的空间名[media namespace name] |
|
10 | + public $bucket; // OSS的空间名[media bucket name] |
|
11 | + public $insertOnly; // 是否可覆盖[upload mode. it's not allowd uploading the same name files] |
|
12 | + public $expiration; // 过期时间[expiration time, unix time, in milliseconds] |
|
13 | 13 | |
14 | 14 | /*如下属性是可选的[The following attributes are optional]*/ |
15 | - public $detectMime = Conf::DETECT_MIME_TRUE; // 是否进行类型检测[is auto detecte media file mime type, default is true] |
|
16 | - public $dir; // 路径[media file dir, magic vars and custom vars are supported] |
|
17 | - public $name; // 上传到服务端的文件名[media file name, magic vars and custom vars are supported] |
|
18 | - public $sizeLimit; // 文件大小限制[upload size limited, in bytes] |
|
19 | - public $mimeLimit; // 文件类型限制[upload mime type limited] |
|
20 | - public $callbackUrl; // 回调URL [callback urls, ip address is recommended] |
|
21 | - public $callbackHost; // 回调时Host [callback host] |
|
22 | - public $callbackBody; // 回调时Body [callback body, magic vars and custom vars are supported] |
|
23 | - public $callbackBodyType; // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8'] |
|
24 | - public $returnUrl; // 上传完成之后,303跳转的Url [return url, when return code is 303] |
|
25 | - public $returnBody; // 上传完成返回体 [return body, magic vars and custom vars are supported] |
|
26 | - public $mediaEncode; // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string] |
|
15 | + public $detectMime = Conf::DETECT_MIME_TRUE; // 是否进行类型检测[is auto detecte media file mime type, default is true] |
|
16 | + public $dir; // 路径[media file dir, magic vars and custom vars are supported] |
|
17 | + public $name; // 上传到服务端的文件名[media file name, magic vars and custom vars are supported] |
|
18 | + public $sizeLimit; // 文件大小限制[upload size limited, in bytes] |
|
19 | + public $mimeLimit; // 文件类型限制[upload mime type limited] |
|
20 | + public $callbackUrl; // 回调URL [callback urls, ip address is recommended] |
|
21 | + public $callbackHost; // 回调时Host [callback host] |
|
22 | + public $callbackBody; // 回调时Body [callback body, magic vars and custom vars are supported] |
|
23 | + public $callbackBodyType; // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8'] |
|
24 | + public $returnUrl; // 上传完成之后,303跳转的Url [return url, when return code is 303] |
|
25 | + public $returnBody; // 上传完成返回体 [return body, magic vars and custom vars are supported] |
|
26 | + public $mediaEncode; // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string] |
|
27 | 27 | |
28 | 28 | public function __construct($option) |
29 | 29 | { |
@@ -4,192 +4,192 @@ |
||
4 | 4 | /**管理时的选项*/ |
5 | 5 | final class ManageOption extends ResourceInfo |
6 | 6 | { |
7 | - /*以下属性是”获取资源列表"方法所需的属性。即listFiles()、listDirs()方法中的参数 */ |
|
8 | - private $currentPage; //当前页号 |
|
9 | - private $pageSize; //每页的大小 |
|
10 | - /* 以下属性是"扫描黄图和广告图"方法所需的属性。即scanPorn()和scanAdvertising方法中的参数 */ |
|
11 | - private $filesArray; |
|
12 | - private $urlsArray; |
|
13 | - /* 以下属性是"鉴黄反馈"方法所需的属性。即pornFeedback()方法中的参数 */ |
|
14 | - private $pornFbArray; |
|
15 | - /** |
|
16 | - * UploadPolicy的构造函数 |
|
17 | - */ |
|
18 | - public function __construct($namespace = null) |
|
19 | - { |
|
20 | - $this->namespace = $namespace; |
|
21 | - $this->currentPage = 1; |
|
22 | - $this->pageSize = 10; |
|
23 | - } |
|
7 | + /*以下属性是”获取资源列表"方法所需的属性。即listFiles()、listDirs()方法中的参数 */ |
|
8 | + private $currentPage; //当前页号 |
|
9 | + private $pageSize; //每页的大小 |
|
10 | + /* 以下属性是"扫描黄图和广告图"方法所需的属性。即scanPorn()和scanAdvertising方法中的参数 */ |
|
11 | + private $filesArray; |
|
12 | + private $urlsArray; |
|
13 | + /* 以下属性是"鉴黄反馈"方法所需的属性。即pornFeedback()方法中的参数 */ |
|
14 | + private $pornFbArray; |
|
15 | + /** |
|
16 | + * UploadPolicy的构造函数 |
|
17 | + */ |
|
18 | + public function __construct($namespace = null) |
|
19 | + { |
|
20 | + $this->namespace = $namespace; |
|
21 | + $this->currentPage = 1; |
|
22 | + $this->pageSize = 10; |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * 生成文件列表listFiles()方法所需的参数 |
|
27 | - */ |
|
28 | - public function buildListFilesParas() |
|
29 | - { |
|
30 | - return "namespace=" . $this->namespace . "&dir=" . urlencode($this->dir) . |
|
31 | - "¤tPage=" . $this->currentPage . "&pageSize=" . $this->pageSize; |
|
32 | - } |
|
25 | + /** |
|
26 | + * 生成文件列表listFiles()方法所需的参数 |
|
27 | + */ |
|
28 | + public function buildListFilesParas() |
|
29 | + { |
|
30 | + return "namespace=" . $this->namespace . "&dir=" . urlencode($this->dir) . |
|
31 | + "¤tPage=" . $this->currentPage . "&pageSize=" . $this->pageSize; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * 校验待检测资源信息是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $bodyArray} |
|
36 | - */ |
|
37 | - public function checkFilesAndUrls() |
|
38 | - { |
|
39 | - if (empty($this->filesArray) && empty($this->urlsArray)) { |
|
40 | - return array(false, "resource's info is empty"); //待检测资源不能均为空,反馈错误 |
|
41 | - } elseif (!empty($this->filesArray) && !empty($this->urlsArray)) { |
|
42 | - return array(false, "resource and url could not exist all at once"); //均存在时,反馈错误 |
|
43 | - } |
|
44 | - $bodyArray = array(); |
|
45 | - $resourceStr = ''; |
|
46 | - if (!empty($this->filesArray)) { |
|
47 | - //检测文件是否合法。若合法则返回http请求体所需参数 |
|
48 | - foreach ($this->filesArray as $resourceInfo) { |
|
49 | - list($valid, $msg) = $resourceInfo->checkResourceInfo(true, true); //检测文件信息是否合法 |
|
50 | - if (!$valid) { |
|
51 | - return array($valid, $msg); |
|
52 | - } |
|
53 | - $resourceStr .= (empty($resourceStr) ? null : ';'); |
|
54 | - $resourceStr .= $resourceInfo->buildResourceId(); |
|
55 | - } |
|
56 | - $bodyArray['resourceId'] = $resourceStr; |
|
57 | - } elseif (!empty($this->urlsArray)) { |
|
58 | - //检测URL是否合法。若合法则返回http请求体所需参数 |
|
59 | - foreach ($this->urlsArray as $url) { |
|
60 | - if (empty($url)) { |
|
61 | - return array(false, "url's info is invalid"); |
|
62 | - } |
|
63 | - $resourceStr .= (empty($resourceStr) ? null : ';'); |
|
64 | - $resourceStr .= $this->urlencode_ch($url); |
|
65 | - } |
|
66 | - $bodyArray['url'] = $resourceStr; |
|
67 | - } |
|
68 | - return array(true, 'valid', $bodyArray); |
|
69 | - } |
|
34 | + /** |
|
35 | + * 校验待检测资源信息是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $bodyArray} |
|
36 | + */ |
|
37 | + public function checkFilesAndUrls() |
|
38 | + { |
|
39 | + if (empty($this->filesArray) && empty($this->urlsArray)) { |
|
40 | + return array(false, "resource's info is empty"); //待检测资源不能均为空,反馈错误 |
|
41 | + } elseif (!empty($this->filesArray) && !empty($this->urlsArray)) { |
|
42 | + return array(false, "resource and url could not exist all at once"); //均存在时,反馈错误 |
|
43 | + } |
|
44 | + $bodyArray = array(); |
|
45 | + $resourceStr = ''; |
|
46 | + if (!empty($this->filesArray)) { |
|
47 | + //检测文件是否合法。若合法则返回http请求体所需参数 |
|
48 | + foreach ($this->filesArray as $resourceInfo) { |
|
49 | + list($valid, $msg) = $resourceInfo->checkResourceInfo(true, true); //检测文件信息是否合法 |
|
50 | + if (!$valid) { |
|
51 | + return array($valid, $msg); |
|
52 | + } |
|
53 | + $resourceStr .= (empty($resourceStr) ? null : ';'); |
|
54 | + $resourceStr .= $resourceInfo->buildResourceId(); |
|
55 | + } |
|
56 | + $bodyArray['resourceId'] = $resourceStr; |
|
57 | + } elseif (!empty($this->urlsArray)) { |
|
58 | + //检测URL是否合法。若合法则返回http请求体所需参数 |
|
59 | + foreach ($this->urlsArray as $url) { |
|
60 | + if (empty($url)) { |
|
61 | + return array(false, "url's info is invalid"); |
|
62 | + } |
|
63 | + $resourceStr .= (empty($resourceStr) ? null : ';'); |
|
64 | + $resourceStr .= $this->urlencode_ch($url); |
|
65 | + } |
|
66 | + $bodyArray['url'] = $resourceStr; |
|
67 | + } |
|
68 | + return array(true, 'valid', $bodyArray); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * 生成扫描黄图scanPorn()方法所需的参数 |
|
73 | - */ |
|
74 | - public function buildScanPornParas() |
|
75 | - { |
|
76 | - $bodyArray = array(); |
|
77 | - if (!empty($this->filesArray)) { |
|
78 | - $resourceStr = ''; |
|
79 | - foreach ($this->filesArray as $resourceInfo) { |
|
80 | - $resourceStr .= (empty($resourceStr) ? null : ';'); |
|
81 | - $resourceStr .= $resourceInfo->buildResourceId(); |
|
82 | - } |
|
83 | - $bodyArray['resourceId'] = $resourceStr; |
|
84 | - } elseif (!empty($this->urlsArray)) { |
|
85 | - $urlStr = ''; |
|
86 | - foreach ($this->urlsArray as $url) { |
|
87 | - $urlStr .= (empty($urlStr) ? null : ';'); |
|
88 | - $urlStr .= urlencode($url); |
|
89 | - } |
|
90 | - $bodyArray['url'] = $urlStr; |
|
91 | - } |
|
92 | - return $bodyArray; |
|
93 | - } |
|
71 | + /** |
|
72 | + * 生成扫描黄图scanPorn()方法所需的参数 |
|
73 | + */ |
|
74 | + public function buildScanPornParas() |
|
75 | + { |
|
76 | + $bodyArray = array(); |
|
77 | + if (!empty($this->filesArray)) { |
|
78 | + $resourceStr = ''; |
|
79 | + foreach ($this->filesArray as $resourceInfo) { |
|
80 | + $resourceStr .= (empty($resourceStr) ? null : ';'); |
|
81 | + $resourceStr .= $resourceInfo->buildResourceId(); |
|
82 | + } |
|
83 | + $bodyArray['resourceId'] = $resourceStr; |
|
84 | + } elseif (!empty($this->urlsArray)) { |
|
85 | + $urlStr = ''; |
|
86 | + foreach ($this->urlsArray as $url) { |
|
87 | + $urlStr .= (empty($urlStr) ? null : ';'); |
|
88 | + $urlStr .= urlencode($url); |
|
89 | + } |
|
90 | + $bodyArray['url'] = $urlStr; |
|
91 | + } |
|
92 | + return $bodyArray; |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * 生成扫描广告图scanAdvertising()方法所需的参数 |
|
97 | - */ |
|
98 | - public function buildScanAdvertisingParas() |
|
99 | - { |
|
100 | - return $this->buildScanPornParas(); |
|
101 | - } |
|
95 | + /** |
|
96 | + * 生成扫描广告图scanAdvertising()方法所需的参数 |
|
97 | + */ |
|
98 | + public function buildScanAdvertisingParas() |
|
99 | + { |
|
100 | + return $this->buildScanPornParas(); |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * 校验鉴黄反馈信息是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody} |
|
105 | - */ |
|
106 | - public function checkPornFeedbackInfos() |
|
107 | - { |
|
108 | - $httpBody = ''; |
|
109 | - if (empty($this->pornFbArray)) { |
|
110 | - return array(false, "porn feedback info is empty", null); //鉴黄反馈信息为空,反馈错误 |
|
111 | - } |
|
112 | - foreach ($this->pornFbArray as $pornFbInfo) { |
|
113 | - $resourceInfo = $pornFbInfo['file']; //图片信息 |
|
114 | - list($valid, $msg) = $resourceInfo->checkResourceInfo(true, true); //检测图片信息是否合法 |
|
115 | - if (!$valid) { |
|
116 | - return array($valid, $msg, null); |
|
117 | - } |
|
118 | - $type = $pornFbInfo['type']; |
|
119 | - $wrong = $pornFbInfo['wrong']; |
|
120 | - if (!isset($type) || ($type != 0 && $type != 1) || !is_bool($wrong)) { |
|
121 | - return array(false, "parameters 'type' or 'wrong' is invalid", null); //参数type取值0、1, wrong是bool类型 |
|
122 | - } |
|
123 | - $score = $pornFbInfo['score']; |
|
124 | - if ($wrong && (!isset($score) || $score < 0 || $score > 1)) { |
|
125 | - return array(false, "parameters 'score' is invalid", null); //当"wrong"=true时,参数score必须有,且取值范围为[0,1] |
|
126 | - } |
|
127 | - $pornFbInfo['file'] = $resourceInfo->toArray(); //将图片信息对象,转换为数组,并保存 |
|
128 | - $httpBody .= (empty($httpBody) ? null : '&'); //添加分隔符 |
|
129 | - $httpBody .= "feedback=" . urlencode(json_encode($pornFbInfo, true)); //urlencode编码 |
|
130 | - } |
|
131 | - return array(true, "valid", $httpBody); //鉴黄反馈信息合法,并返回http请求体 |
|
132 | - } |
|
133 | - /*###################下面是属性的get和set方法###############*/ |
|
134 | - /**设置当前页号*/ |
|
135 | - public function setCurrentPage($currentPage) |
|
136 | - { |
|
137 | - $this->currentPage = $currentPage; |
|
138 | - return $this; |
|
139 | - } |
|
103 | + /** |
|
104 | + * 校验鉴黄反馈信息是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody} |
|
105 | + */ |
|
106 | + public function checkPornFeedbackInfos() |
|
107 | + { |
|
108 | + $httpBody = ''; |
|
109 | + if (empty($this->pornFbArray)) { |
|
110 | + return array(false, "porn feedback info is empty", null); //鉴黄反馈信息为空,反馈错误 |
|
111 | + } |
|
112 | + foreach ($this->pornFbArray as $pornFbInfo) { |
|
113 | + $resourceInfo = $pornFbInfo['file']; //图片信息 |
|
114 | + list($valid, $msg) = $resourceInfo->checkResourceInfo(true, true); //检测图片信息是否合法 |
|
115 | + if (!$valid) { |
|
116 | + return array($valid, $msg, null); |
|
117 | + } |
|
118 | + $type = $pornFbInfo['type']; |
|
119 | + $wrong = $pornFbInfo['wrong']; |
|
120 | + if (!isset($type) || ($type != 0 && $type != 1) || !is_bool($wrong)) { |
|
121 | + return array(false, "parameters 'type' or 'wrong' is invalid", null); //参数type取值0、1, wrong是bool类型 |
|
122 | + } |
|
123 | + $score = $pornFbInfo['score']; |
|
124 | + if ($wrong && (!isset($score) || $score < 0 || $score > 1)) { |
|
125 | + return array(false, "parameters 'score' is invalid", null); //当"wrong"=true时,参数score必须有,且取值范围为[0,1] |
|
126 | + } |
|
127 | + $pornFbInfo['file'] = $resourceInfo->toArray(); //将图片信息对象,转换为数组,并保存 |
|
128 | + $httpBody .= (empty($httpBody) ? null : '&'); //添加分隔符 |
|
129 | + $httpBody .= "feedback=" . urlencode(json_encode($pornFbInfo, true)); //urlencode编码 |
|
130 | + } |
|
131 | + return array(true, "valid", $httpBody); //鉴黄反馈信息合法,并返回http请求体 |
|
132 | + } |
|
133 | + /*###################下面是属性的get和set方法###############*/ |
|
134 | + /**设置当前页号*/ |
|
135 | + public function setCurrentPage($currentPage) |
|
136 | + { |
|
137 | + $this->currentPage = $currentPage; |
|
138 | + return $this; |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * 设置每页的大小 |
|
143 | - */ |
|
144 | - public function setPageSize($pageSize) |
|
145 | - { |
|
146 | - $this->pageSize = $pageSize; |
|
147 | - return $this; |
|
148 | - } |
|
141 | + /** |
|
142 | + * 设置每页的大小 |
|
143 | + */ |
|
144 | + public function setPageSize($pageSize) |
|
145 | + { |
|
146 | + $this->pageSize = $pageSize; |
|
147 | + return $this; |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * 添加待扫描文件信息。 |
|
152 | - */ |
|
153 | - public function addResource($namespace = null, $dir = null, $name = null) |
|
154 | - { |
|
155 | - if (!isset($this->filesArray)) { |
|
156 | - $this->filesArray = array(); |
|
157 | - } |
|
158 | - array_push($this->filesArray, new ResourceInfo($namespace, $dir, $name)); |
|
159 | - } |
|
150 | + /** |
|
151 | + * 添加待扫描文件信息。 |
|
152 | + */ |
|
153 | + public function addResource($namespace = null, $dir = null, $name = null) |
|
154 | + { |
|
155 | + if (!isset($this->filesArray)) { |
|
156 | + $this->filesArray = array(); |
|
157 | + } |
|
158 | + array_push($this->filesArray, new ResourceInfo($namespace, $dir, $name)); |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * 添加待扫描URL信息。 |
|
163 | - */ |
|
164 | - public function addUrl($url) |
|
165 | - { |
|
166 | - if (!isset($this->urlsArray)) { |
|
167 | - $this->urlsArray = array(); |
|
168 | - } |
|
169 | - array_push($this->urlsArray, $url); |
|
170 | - } |
|
161 | + /** |
|
162 | + * 添加待扫描URL信息。 |
|
163 | + */ |
|
164 | + public function addUrl($url) |
|
165 | + { |
|
166 | + if (!isset($this->urlsArray)) { |
|
167 | + $this->urlsArray = array(); |
|
168 | + } |
|
169 | + array_push($this->urlsArray, $url); |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * 添加鉴黄反馈信息。 |
|
174 | - * @param string $namespace 空间名[必须]。 |
|
175 | - * @param string $dir 路径。为空则默认根目录 |
|
176 | - * @param string $name 文件名。不能为空 |
|
177 | - * @param bool $type 黄图类型[必须]。0或者1,0是非黄图,1是黄图 |
|
178 | - * @param bool $wrong 鉴黄判断[必须]。true代表用户认为多媒体鉴黄服务的结果有问题。当为true的时候必须传score |
|
179 | - * @param float $score 黄图分值。[可选]取值范围[0-1],值越高则是黄图可能性越高 |
|
180 | - */ |
|
181 | - public function addPornFbInfo($namespace = null, $dir = null, $name = null, $type = null, $wrong = null, $score = null) |
|
182 | - { |
|
183 | - if (!isset($this->pornFbArray)) { |
|
184 | - $this->pornFbArray = array(); |
|
185 | - } |
|
186 | - $pornFbInfo = array( |
|
187 | - "file" => new ResourceInfo($namespace, $dir, $name), |
|
188 | - "type" => $type, "wrong" => $wrong |
|
189 | - ); |
|
190 | - if ($wrong) { |
|
191 | - $pornFbInfo['score'] = $score; //当$wrong为true的时候必须传score |
|
192 | - } |
|
193 | - array_push($this->pornFbArray, $pornFbInfo); |
|
194 | - } |
|
172 | + /** |
|
173 | + * 添加鉴黄反馈信息。 |
|
174 | + * @param string $namespace 空间名[必须]。 |
|
175 | + * @param string $dir 路径。为空则默认根目录 |
|
176 | + * @param string $name 文件名。不能为空 |
|
177 | + * @param bool $type 黄图类型[必须]。0或者1,0是非黄图,1是黄图 |
|
178 | + * @param bool $wrong 鉴黄判断[必须]。true代表用户认为多媒体鉴黄服务的结果有问题。当为true的时候必须传score |
|
179 | + * @param float $score 黄图分值。[可选]取值范围[0-1],值越高则是黄图可能性越高 |
|
180 | + */ |
|
181 | + public function addPornFbInfo($namespace = null, $dir = null, $name = null, $type = null, $wrong = null, $score = null) |
|
182 | + { |
|
183 | + if (!isset($this->pornFbArray)) { |
|
184 | + $this->pornFbArray = array(); |
|
185 | + } |
|
186 | + $pornFbInfo = array( |
|
187 | + "file" => new ResourceInfo($namespace, $dir, $name), |
|
188 | + "type" => $type, "wrong" => $wrong |
|
189 | + ); |
|
190 | + if ($wrong) { |
|
191 | + $pornFbInfo['score'] = $score; //当$wrong为true的时候必须传score |
|
192 | + } |
|
193 | + array_push($this->pornFbArray, $pornFbInfo); |
|
194 | + } |
|
195 | 195 | } |
@@ -5,8 +5,8 @@ |
||
5 | 5 | final class ManageOption extends ResourceInfo |
6 | 6 | { |
7 | 7 | /*以下属性是”获取资源列表"方法所需的属性。即listFiles()、listDirs()方法中的参数 */ |
8 | - private $currentPage; //当前页号 |
|
9 | - private $pageSize; //每页的大小 |
|
8 | + private $currentPage; //当前页号 |
|
9 | + private $pageSize; //每页的大小 |
|
10 | 10 | /* 以下属性是"扫描黄图和广告图"方法所需的属性。即scanPorn()和scanAdvertising方法中的参数 */ |
11 | 11 | private $filesArray; |
12 | 12 | private $urlsArray; |
@@ -3,39 +3,39 @@ |
||
3 | 3 | |
4 | 4 | class Conf |
5 | 5 | { |
6 | - const CHARSET = "UTF-8"; |
|
7 | - const SDK_VERSION = '2.0.3'; |
|
6 | + const CHARSET = "UTF-8"; |
|
7 | + const SDK_VERSION = '2.0.3'; |
|
8 | 8 | |
9 | - const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com"; //文件上传的地址 |
|
10 | - const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com"; //服务管理的地址 |
|
11 | - const MANAGE_API_VERSION = "3.0"; //资源管理接口版本 |
|
12 | - const SCAN_PORN_VERSION = "3.1"; //黄图扫描接口版本 |
|
13 | - const MEDIA_ENCODE_VERSION = "3.0"; //媒体转码接口版本 |
|
9 | + const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com"; //文件上传的地址 |
|
10 | + const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com"; //服务管理的地址 |
|
11 | + const MANAGE_API_VERSION = "3.0"; //资源管理接口版本 |
|
12 | + const SCAN_PORN_VERSION = "3.1"; //黄图扫描接口版本 |
|
13 | + const MEDIA_ENCODE_VERSION = "3.0"; //媒体转码接口版本 |
|
14 | 14 | |
15 | - const UPLOAD_API_UPLOAD = "/api/proxy/upload"; |
|
16 | - const UPLOAD_API_BLOCK_INIT = "/api/proxy/blockInit"; |
|
17 | - const UPLOAD_API_BLOCK_UPLOAD = "/api/proxy/blockUpload"; |
|
18 | - const UPLOAD_API_BLOCK_COMPLETE = "/api/proxy/blockComplete"; |
|
19 | - const UPLOAD_API_BLOCK_CANCEL = "/api/proxy/blockCancel"; |
|
15 | + const UPLOAD_API_UPLOAD = "/api/proxy/upload"; |
|
16 | + const UPLOAD_API_BLOCK_INIT = "/api/proxy/blockInit"; |
|
17 | + const UPLOAD_API_BLOCK_UPLOAD = "/api/proxy/blockUpload"; |
|
18 | + const UPLOAD_API_BLOCK_COMPLETE = "/api/proxy/blockComplete"; |
|
19 | + const UPLOAD_API_BLOCK_CANCEL = "/api/proxy/blockCancel"; |
|
20 | 20 | |
21 | - const TYPE_TOP = "TOP"; |
|
22 | - const TYPE_CLOUD = "CLOUD"; |
|
21 | + const TYPE_TOP = "TOP"; |
|
22 | + const TYPE_CLOUD = "CLOUD"; |
|
23 | 23 | |
24 | - const DETECT_MIME_TRUE = 1; //检测MimeType |
|
25 | - const DETECT_MIME_NONE = 0; //不检测MimeType |
|
26 | - const INSERT_ONLY_TRUE = 1; //文件上传不可覆盖 |
|
27 | - const INSERT_ONLY_NONE = 0; //文件上传可覆盖 |
|
24 | + const DETECT_MIME_TRUE = 1; //检测MimeType |
|
25 | + const DETECT_MIME_NONE = 0; //不检测MimeType |
|
26 | + const INSERT_ONLY_TRUE = 1; //文件上传不可覆盖 |
|
27 | + const INSERT_ONLY_NONE = 0; //文件上传可覆盖 |
|
28 | 28 | |
29 | - const MIN_OBJ_SIZE = 1; //1024*100; |
|
30 | - const HTTP_TIMEOUT = 30; //http的超时时间:30s |
|
31 | - const HTTP_RETRY = 1; //http失败后重试:1 |
|
29 | + const MIN_OBJ_SIZE = 1; //1024*100; |
|
30 | + const HTTP_TIMEOUT = 30; //http的超时时间:30s |
|
31 | + const HTTP_RETRY = 1; //http失败后重试:1 |
|
32 | 32 | |
33 | - const BLOCK_MIN_SIZE = 102400; //文件分片最小值:1024*100; 100K |
|
34 | - const BLOCK_DEFF_SIZE = 209715200; //文件分片默认值:1024*1024*2; 2M |
|
35 | - const BLOCK_MAX_SIZE = 104857600; //文件分片最大值:1024*1024*10; 10M |
|
33 | + const BLOCK_MIN_SIZE = 102400; //文件分片最小值:1024*100; 100K |
|
34 | + const BLOCK_DEFF_SIZE = 209715200; //文件分片默认值:1024*1024*2; 2M |
|
35 | + const BLOCK_MAX_SIZE = 104857600; //文件分片最大值:1024*1024*10; 10M |
|
36 | 36 | |
37 | - const CURL_ERR_LOG = "curl_error.log"; //curl请求时的错误日志信息 |
|
37 | + const CURL_ERR_LOG = "curl_error.log"; //curl请求时的错误日志信息 |
|
38 | 38 | |
39 | - const RUN_LEVEL_RELEASE = 1; //release级别 |
|
40 | - const RUN_LEVEL_DEBUG = 2; //debug级别 |
|
39 | + const RUN_LEVEL_RELEASE = 1; //release级别 |
|
40 | + const RUN_LEVEL_DEBUG = 2; //debug级别 |
|
41 | 41 | } |
@@ -6,11 +6,11 @@ discard block |
||
6 | 6 | const CHARSET = "UTF-8"; |
7 | 7 | const SDK_VERSION = '2.0.3'; |
8 | 8 | |
9 | - const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com"; //文件上传的地址 |
|
10 | - const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com"; //服务管理的地址 |
|
11 | - const MANAGE_API_VERSION = "3.0"; //资源管理接口版本 |
|
12 | - const SCAN_PORN_VERSION = "3.1"; //黄图扫描接口版本 |
|
13 | - const MEDIA_ENCODE_VERSION = "3.0"; //媒体转码接口版本 |
|
9 | + const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com"; //文件上传的地址 |
|
10 | + const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com"; //服务管理的地址 |
|
11 | + const MANAGE_API_VERSION = "3.0"; //资源管理接口版本 |
|
12 | + const SCAN_PORN_VERSION = "3.1"; //黄图扫描接口版本 |
|
13 | + const MEDIA_ENCODE_VERSION = "3.0"; //媒体转码接口版本 |
|
14 | 14 | |
15 | 15 | const UPLOAD_API_UPLOAD = "/api/proxy/upload"; |
16 | 16 | const UPLOAD_API_BLOCK_INIT = "/api/proxy/blockInit"; |
@@ -21,21 +21,21 @@ discard block |
||
21 | 21 | const TYPE_TOP = "TOP"; |
22 | 22 | const TYPE_CLOUD = "CLOUD"; |
23 | 23 | |
24 | - const DETECT_MIME_TRUE = 1; //检测MimeType |
|
25 | - const DETECT_MIME_NONE = 0; //不检测MimeType |
|
26 | - const INSERT_ONLY_TRUE = 1; //文件上传不可覆盖 |
|
27 | - const INSERT_ONLY_NONE = 0; //文件上传可覆盖 |
|
24 | + const DETECT_MIME_TRUE = 1; //检测MimeType |
|
25 | + const DETECT_MIME_NONE = 0; //不检测MimeType |
|
26 | + const INSERT_ONLY_TRUE = 1; //文件上传不可覆盖 |
|
27 | + const INSERT_ONLY_NONE = 0; //文件上传可覆盖 |
|
28 | 28 | |
29 | - const MIN_OBJ_SIZE = 1; //1024*100; |
|
30 | - const HTTP_TIMEOUT = 30; //http的超时时间:30s |
|
31 | - const HTTP_RETRY = 1; //http失败后重试:1 |
|
29 | + const MIN_OBJ_SIZE = 1; //1024*100; |
|
30 | + const HTTP_TIMEOUT = 30; //http的超时时间:30s |
|
31 | + const HTTP_RETRY = 1; //http失败后重试:1 |
|
32 | 32 | |
33 | - const BLOCK_MIN_SIZE = 102400; //文件分片最小值:1024*100; 100K |
|
34 | - const BLOCK_DEFF_SIZE = 209715200; //文件分片默认值:1024*1024*2; 2M |
|
35 | - const BLOCK_MAX_SIZE = 104857600; //文件分片最大值:1024*1024*10; 10M |
|
33 | + const BLOCK_MIN_SIZE = 102400; //文件分片最小值:1024*100; 100K |
|
34 | + const BLOCK_DEFF_SIZE = 209715200; //文件分片默认值:1024*1024*2; 2M |
|
35 | + const BLOCK_MAX_SIZE = 104857600; //文件分片最大值:1024*1024*10; 10M |
|
36 | 36 | |
37 | - const CURL_ERR_LOG = "curl_error.log"; //curl请求时的错误日志信息 |
|
37 | + const CURL_ERR_LOG = "curl_error.log"; //curl请求时的错误日志信息 |
|
38 | 38 | |
39 | - const RUN_LEVEL_RELEASE = 1; //release级别 |
|
40 | - const RUN_LEVEL_DEBUG = 2; //debug级别 |
|
39 | + const RUN_LEVEL_RELEASE = 1; //release级别 |
|
40 | + const RUN_LEVEL_DEBUG = 2; //debug级别 |
|
41 | 41 | } |