Passed
Push — master ( 4428d0...671bc7 )
by xiaohui
02:35
created
sdk/Utils/SnapShotOption.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -5,45 +5,45 @@
 block discarded – undo
5 5
 /**视频截图的参数*/
6 6
 class SnapShotOption extends MediaResOption
7 7
 {
8
-    /** 视频截图的位置,单位为毫秒。该属性必须*/
9
-    private $time;
10
-    /** 通知url,任务结束之后会调用这个url。该属性可选 */
11
-    private $notifyUrl;
12
-    /**检测视频截图参数是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/
13
-    public function checkOptionParameters()
14
-    {
15
-        list($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法
16
-        if (!$valid) {
17
-            return array($valid, $msg, null);
18
-        }
19
-        if (empty($this->time) || !is_int($this->time) || $this->time < 0) {
20
-            return array(false, "time is empty or invalid.", null); // 是否设置时间,且时间是否合法
21
-        }
22
-        return $this->getOptionsHttpBody(); //返回http请求体
23
-    }
8
+	/** 视频截图的位置,单位为毫秒。该属性必须*/
9
+	private $time;
10
+	/** 通知url,任务结束之后会调用这个url。该属性可选 */
11
+	private $notifyUrl;
12
+	/**检测视频截图参数是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/
13
+	public function checkOptionParameters()
14
+	{
15
+		list($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法
16
+		if (!$valid) {
17
+			return array($valid, $msg, null);
18
+		}
19
+		if (empty($this->time) || !is_int($this->time) || $this->time < 0) {
20
+			return array(false, "time is empty or invalid.", null); // 是否设置时间,且时间是否合法
21
+		}
22
+		return $this->getOptionsHttpBody(); //返回http请求体
23
+	}
24 24
 
25
-    /**构建多媒体转码所需的http请求体*/
26
-    public function getOptionsHttpBody()
27
-    {
28
-        //必须的参数
29
-        $httpBody = 'input=' . $this->getInputResId();
30
-        $httpBody .= '&output=' . $this->getOutputResId();
31
-        $httpBody .= '&time=' . $this->time;
32
-        // 可选的参数
33
-        if (isset($this->notifyUrl)) {
34
-            $httpBody .= '&notifyUrl=' . urlencode($this->notifyUrl);
35
-        }
36
-        return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体
37
-    }
25
+	/**构建多媒体转码所需的http请求体*/
26
+	public function getOptionsHttpBody()
27
+	{
28
+		//必须的参数
29
+		$httpBody = 'input=' . $this->getInputResId();
30
+		$httpBody .= '&output=' . $this->getOutputResId();
31
+		$httpBody .= '&time=' . $this->time;
32
+		// 可选的参数
33
+		if (isset($this->notifyUrl)) {
34
+			$httpBody .= '&notifyUrl=' . urlencode($this->notifyUrl);
35
+		}
36
+		return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体
37
+	}
38 38
 
39
-    /**设置视频截图的位置,单位为毫秒。改参数必须设置*/
40
-    public function setTime($time)
41
-    {
42
-        $this->time = $time;
43
-    }
44
-    /**设置截图完成后的通知url。可选*/
45
-    public function setNotifyUrl($notifyUrl)
46
-    {
47
-        $this->notifyUrl = $notifyUrl;
48
-    }
39
+	/**设置视频截图的位置,单位为毫秒。改参数必须设置*/
40
+	public function setTime($time)
41
+	{
42
+		$this->time = $time;
43
+	}
44
+	/**设置截图完成后的通知url。可选*/
45
+	public function setNotifyUrl($notifyUrl)
46
+	{
47
+		$this->notifyUrl = $notifyUrl;
48
+	}
49 49
 }
Please login to merge, or discard this patch.
sdk/Utils/MimeTypes.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -3,138 +3,138 @@
 block discarded – undo
3 3
 
4 4
 class MimeTypes
5 5
 {
6
-    public static $mime_types = array(
7
-        '3gp' => 'video/3gpp', 'ai' => 'application/postscript',
8
-        'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff',
9
-        'aiff' => 'audio/x-aiff', 'asc' => 'text/plain',
10
-        'atom' => 'application/atom+xml', 'au' => 'audio/basic',
11
-        'avi' => 'video/x-msvideo', 'bcpio' => 'application/x-bcpio',
12
-        'bin' => 'application/octet-stream', 'bmp' => 'image/bmp',
13
-        'cdf' => 'application/x-netcdf', 'cgm' => 'image/cgm',
14
-        'class' => 'application/octet-stream',
15
-        'cpio' => 'application/x-cpio',
16
-        'cpt' => 'application/mac-compactpro',
17
-        'csh' => 'application/x-csh', 'css' => 'text/css',
18
-        'dcr' => 'application/x-director', 'dif' => 'video/x-dv',
19
-        'dir' => 'application/x-director', 'djv' => 'image/vnd.djvu',
20
-        'djvu' => 'image/vnd.djvu',
21
-        'dll' => 'application/octet-stream',
22
-        'dmg' => 'application/octet-stream',
23
-        'dms' => 'application/octet-stream',
24
-        'doc' => 'application/msword', 'dtd' => 'application/xml-dtd',
25
-        'dv' => 'video/x-dv', 'dvi' => 'application/x-dvi',
26
-        'dxr' => 'application/x-director',
27
-        'eps' => 'application/postscript', 'etx' => 'text/x-setext',
28
-        'exe' => 'application/octet-stream',
29
-        'ez' => 'application/andrew-inset', 'flv' => 'video/x-flv',
30
-        'gif' => 'image/gif', 'gram' => 'application/srgs',
31
-        'grxml' => 'application/srgs+xml',
32
-        'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip',
33
-        'hdf' => 'application/x-hdf',
34
-        'hqx' => 'application/mac-binhex40', 'htm' => 'text/html',
35
-        'html' => 'text/html', 'ice' => 'x-conference/x-cooltalk',
36
-        'ico' => 'image/x-icon', 'ics' => 'text/calendar',
37
-        'ief' => 'image/ief', 'ifb' => 'text/calendar',
38
-        'iges' => 'model/iges', 'igs' => 'model/iges',
39
-        'jnlp' => 'application/x-java-jnlp-file', 'jp2' => 'image/jp2',
40
-        'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg',
41
-        'jpg' => 'image/jpeg', 'js' => 'application/x-javascript',
42
-        'kar' => 'audio/midi', 'latex' => 'application/x-latex',
43
-        'lha' => 'application/octet-stream',
44
-        'lzh' => 'application/octet-stream',
45
-        'm3u' => 'audio/x-mpegurl', 'm4a' => 'audio/mp4a-latm',
46
-        'm4p' => 'audio/mp4a-latm', 'm4u' => 'video/vnd.mpegurl',
47
-        'm4v' => 'video/x-m4v', 'mac' => 'image/x-macpaint',
48
-        'man' => 'application/x-troff-man',
49
-        'mathml' => 'application/mathml+xml',
50
-        'me' => 'application/x-troff-me', 'mesh' => 'model/mesh',
51
-        'mid' => 'audio/midi', 'midi' => 'audio/midi',
52
-        'mif' => 'application/vnd.mif', 'mov' => 'video/quicktime',
53
-        'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg',
54
-        'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4',
55
-        'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg',
56
-        'mpg' => 'video/mpeg', 'mpga' => 'audio/mpeg',
57
-        'ms' => 'application/x-troff-ms', 'msh' => 'model/mesh',
58
-        'mxu' => 'video/vnd.mpegurl', 'nc' => 'application/x-netcdf',
59
-        'oda' => 'application/oda', 'ogg' => 'application/ogg',
60
-        'ogv' => 'video/ogv', 'pbm' => 'image/x-portable-bitmap',
61
-        'pct' => 'image/pict', 'pdb' => 'chemical/x-pdb',
62
-        'pdf' => 'application/pdf',
63
-        'pgm' => 'image/x-portable-graymap',
64
-        'pgn' => 'application/x-chess-pgn', 'pic' => 'image/pict',
65
-        'pict' => 'image/pict', 'png' => 'image/png',
66
-        'pnm' => 'image/x-portable-anymap',
67
-        'pnt' => 'image/x-macpaint', 'pntg' => 'image/x-macpaint',
68
-        'ppm' => 'image/x-portable-pixmap',
69
-        'ppt' => 'application/vnd.ms-powerpoint',
70
-        'ps' => 'application/postscript', 'qt' => 'video/quicktime',
71
-        'qti' => 'image/x-quicktime', 'qtif' => 'image/x-quicktime',
72
-        'ra' => 'audio/x-pn-realaudio',
73
-        'ram' => 'audio/x-pn-realaudio', 'ras' => 'image/x-cmu-raster',
74
-        'rdf' => 'application/rdf+xml', 'rgb' => 'image/x-rgb',
75
-        'rm' => 'application/vnd.rn-realmedia',
76
-        'roff' => 'application/x-troff', 'rtf' => 'text/rtf',
77
-        'rtx' => 'text/richtext', 'sgm' => 'text/sgml',
78
-        'sgml' => 'text/sgml', 'sh' => 'application/x-sh',
79
-        'shar' => 'application/x-shar', 'silo' => 'model/mesh',
80
-        'sit' => 'application/x-stuffit',
81
-        'skd' => 'application/x-koan', 'skm' => 'application/x-koan',
82
-        'skp' => 'application/x-koan', 'skt' => 'application/x-koan',
83
-        'smi' => 'application/smil', 'smil' => 'application/smil',
84
-        'snd' => 'audio/basic', 'so' => 'application/octet-stream',
85
-        'spl' => 'application/x-futuresplash',
86
-        'src' => 'application/x-wais-source',
87
-        'sv4cpio' => 'application/x-sv4cpio',
88
-        'sv4crc' => 'application/x-sv4crc', 'svg' => 'image/svg+xml',
89
-        'swf' => 'application/x-shockwave-flash',
90
-        't' => 'application/x-troff', 'tar' => 'application/x-tar',
91
-        'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex',
92
-        'texi' => 'application/x-texinfo',
93
-        'texinfo' => 'application/x-texinfo', 'tif' => 'image/tiff',
94
-        'tiff' => 'image/tiff', 'tr' => 'application/x-troff',
95
-        'tsv' => 'text/tab-separated-values', 'txt' => 'text/plain',
96
-        'ustar' => 'application/x-ustar',
97
-        'vcd' => 'application/x-cdlink', 'vrml' => 'model/vrml',
98
-        'vxml' => 'application/voicexml+xml', 'wav' => 'audio/x-wav',
99
-        'wbmp' => 'image/vnd.wap.wbmp',
100
-        'wbxml' => 'application/vnd.wap.wbxml', 'webm' => 'video/webm',
101
-        'wml' => 'text/vnd.wap.wml',
102
-        'wmlc' => 'application/vnd.wap.wmlc',
103
-        'wmls' => 'text/vnd.wap.wmlscript',
104
-        'wmlsc' => 'application/vnd.wap.wmlscriptc',
105
-        'wmv' => 'video/x-ms-wmv', 'wrl' => 'model/vrml',
106
-        'xbm' => 'image/x-xbitmap', 'xht' => 'application/xhtml+xml',
107
-        'xhtml' => 'application/xhtml+xml',
108
-        'xls' => 'application/vnd.ms-excel',
109
-        'xml' => 'application/xml', 'xpm' => 'image/x-xpixmap',
110
-        'xsl' => 'application/xml', 'xslt' => 'application/xslt+xml',
111
-        'xul' => 'application/vnd.mozilla.xul+xml',
112
-        'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-xyz',
113
-        'zip' => 'application/zip',
114
-        "apk" => "application/vnd.android.package-archive",
115
-        "bin" => "application/octet-stream",
116
-        "cab" => "application/vnd.ms-cab-compressed",
117
-        "gb" => "application/chinese-gb",
118
-        "gba" => "application/octet-stream",
119
-        "gbc" => "application/octet-stream",
120
-        "jad" => "text/vnd.sun.j2me.app-descriptor",
121
-        "jar" => "application/java-archive",
122
-        "nes" => "application/octet-stream",
123
-        "rar" => "application/x-rar-compressed",
124
-        "sis" => "application/vnd.symbian.install",
125
-        "sisx" => "x-epoc/x-sisx-app",
126
-        "smc" => "application/octet-stream",
127
-        "smd" => "application/octet-stream",
128
-        "swf" => "application/x-shockwave-flash",
129
-        "zip" => "application/x-zip-compressed",
130
-        "wap" => "text/vnd.wap.wml wml", "mrp" => "application/mrp",
131
-        "wma" => "audio/x-ms-wma",
132
-        "lrc" => "application/lrc"
133
-    );
6
+	public static $mime_types = array(
7
+		'3gp' => 'video/3gpp', 'ai' => 'application/postscript',
8
+		'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff',
9
+		'aiff' => 'audio/x-aiff', 'asc' => 'text/plain',
10
+		'atom' => 'application/atom+xml', 'au' => 'audio/basic',
11
+		'avi' => 'video/x-msvideo', 'bcpio' => 'application/x-bcpio',
12
+		'bin' => 'application/octet-stream', 'bmp' => 'image/bmp',
13
+		'cdf' => 'application/x-netcdf', 'cgm' => 'image/cgm',
14
+		'class' => 'application/octet-stream',
15
+		'cpio' => 'application/x-cpio',
16
+		'cpt' => 'application/mac-compactpro',
17
+		'csh' => 'application/x-csh', 'css' => 'text/css',
18
+		'dcr' => 'application/x-director', 'dif' => 'video/x-dv',
19
+		'dir' => 'application/x-director', 'djv' => 'image/vnd.djvu',
20
+		'djvu' => 'image/vnd.djvu',
21
+		'dll' => 'application/octet-stream',
22
+		'dmg' => 'application/octet-stream',
23
+		'dms' => 'application/octet-stream',
24
+		'doc' => 'application/msword', 'dtd' => 'application/xml-dtd',
25
+		'dv' => 'video/x-dv', 'dvi' => 'application/x-dvi',
26
+		'dxr' => 'application/x-director',
27
+		'eps' => 'application/postscript', 'etx' => 'text/x-setext',
28
+		'exe' => 'application/octet-stream',
29
+		'ez' => 'application/andrew-inset', 'flv' => 'video/x-flv',
30
+		'gif' => 'image/gif', 'gram' => 'application/srgs',
31
+		'grxml' => 'application/srgs+xml',
32
+		'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip',
33
+		'hdf' => 'application/x-hdf',
34
+		'hqx' => 'application/mac-binhex40', 'htm' => 'text/html',
35
+		'html' => 'text/html', 'ice' => 'x-conference/x-cooltalk',
36
+		'ico' => 'image/x-icon', 'ics' => 'text/calendar',
37
+		'ief' => 'image/ief', 'ifb' => 'text/calendar',
38
+		'iges' => 'model/iges', 'igs' => 'model/iges',
39
+		'jnlp' => 'application/x-java-jnlp-file', 'jp2' => 'image/jp2',
40
+		'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg',
41
+		'jpg' => 'image/jpeg', 'js' => 'application/x-javascript',
42
+		'kar' => 'audio/midi', 'latex' => 'application/x-latex',
43
+		'lha' => 'application/octet-stream',
44
+		'lzh' => 'application/octet-stream',
45
+		'm3u' => 'audio/x-mpegurl', 'm4a' => 'audio/mp4a-latm',
46
+		'm4p' => 'audio/mp4a-latm', 'm4u' => 'video/vnd.mpegurl',
47
+		'm4v' => 'video/x-m4v', 'mac' => 'image/x-macpaint',
48
+		'man' => 'application/x-troff-man',
49
+		'mathml' => 'application/mathml+xml',
50
+		'me' => 'application/x-troff-me', 'mesh' => 'model/mesh',
51
+		'mid' => 'audio/midi', 'midi' => 'audio/midi',
52
+		'mif' => 'application/vnd.mif', 'mov' => 'video/quicktime',
53
+		'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg',
54
+		'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4',
55
+		'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg',
56
+		'mpg' => 'video/mpeg', 'mpga' => 'audio/mpeg',
57
+		'ms' => 'application/x-troff-ms', 'msh' => 'model/mesh',
58
+		'mxu' => 'video/vnd.mpegurl', 'nc' => 'application/x-netcdf',
59
+		'oda' => 'application/oda', 'ogg' => 'application/ogg',
60
+		'ogv' => 'video/ogv', 'pbm' => 'image/x-portable-bitmap',
61
+		'pct' => 'image/pict', 'pdb' => 'chemical/x-pdb',
62
+		'pdf' => 'application/pdf',
63
+		'pgm' => 'image/x-portable-graymap',
64
+		'pgn' => 'application/x-chess-pgn', 'pic' => 'image/pict',
65
+		'pict' => 'image/pict', 'png' => 'image/png',
66
+		'pnm' => 'image/x-portable-anymap',
67
+		'pnt' => 'image/x-macpaint', 'pntg' => 'image/x-macpaint',
68
+		'ppm' => 'image/x-portable-pixmap',
69
+		'ppt' => 'application/vnd.ms-powerpoint',
70
+		'ps' => 'application/postscript', 'qt' => 'video/quicktime',
71
+		'qti' => 'image/x-quicktime', 'qtif' => 'image/x-quicktime',
72
+		'ra' => 'audio/x-pn-realaudio',
73
+		'ram' => 'audio/x-pn-realaudio', 'ras' => 'image/x-cmu-raster',
74
+		'rdf' => 'application/rdf+xml', 'rgb' => 'image/x-rgb',
75
+		'rm' => 'application/vnd.rn-realmedia',
76
+		'roff' => 'application/x-troff', 'rtf' => 'text/rtf',
77
+		'rtx' => 'text/richtext', 'sgm' => 'text/sgml',
78
+		'sgml' => 'text/sgml', 'sh' => 'application/x-sh',
79
+		'shar' => 'application/x-shar', 'silo' => 'model/mesh',
80
+		'sit' => 'application/x-stuffit',
81
+		'skd' => 'application/x-koan', 'skm' => 'application/x-koan',
82
+		'skp' => 'application/x-koan', 'skt' => 'application/x-koan',
83
+		'smi' => 'application/smil', 'smil' => 'application/smil',
84
+		'snd' => 'audio/basic', 'so' => 'application/octet-stream',
85
+		'spl' => 'application/x-futuresplash',
86
+		'src' => 'application/x-wais-source',
87
+		'sv4cpio' => 'application/x-sv4cpio',
88
+		'sv4crc' => 'application/x-sv4crc', 'svg' => 'image/svg+xml',
89
+		'swf' => 'application/x-shockwave-flash',
90
+		't' => 'application/x-troff', 'tar' => 'application/x-tar',
91
+		'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex',
92
+		'texi' => 'application/x-texinfo',
93
+		'texinfo' => 'application/x-texinfo', 'tif' => 'image/tiff',
94
+		'tiff' => 'image/tiff', 'tr' => 'application/x-troff',
95
+		'tsv' => 'text/tab-separated-values', 'txt' => 'text/plain',
96
+		'ustar' => 'application/x-ustar',
97
+		'vcd' => 'application/x-cdlink', 'vrml' => 'model/vrml',
98
+		'vxml' => 'application/voicexml+xml', 'wav' => 'audio/x-wav',
99
+		'wbmp' => 'image/vnd.wap.wbmp',
100
+		'wbxml' => 'application/vnd.wap.wbxml', 'webm' => 'video/webm',
101
+		'wml' => 'text/vnd.wap.wml',
102
+		'wmlc' => 'application/vnd.wap.wmlc',
103
+		'wmls' => 'text/vnd.wap.wmlscript',
104
+		'wmlsc' => 'application/vnd.wap.wmlscriptc',
105
+		'wmv' => 'video/x-ms-wmv', 'wrl' => 'model/vrml',
106
+		'xbm' => 'image/x-xbitmap', 'xht' => 'application/xhtml+xml',
107
+		'xhtml' => 'application/xhtml+xml',
108
+		'xls' => 'application/vnd.ms-excel',
109
+		'xml' => 'application/xml', 'xpm' => 'image/x-xpixmap',
110
+		'xsl' => 'application/xml', 'xslt' => 'application/xslt+xml',
111
+		'xul' => 'application/vnd.mozilla.xul+xml',
112
+		'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-xyz',
113
+		'zip' => 'application/zip',
114
+		"apk" => "application/vnd.android.package-archive",
115
+		"bin" => "application/octet-stream",
116
+		"cab" => "application/vnd.ms-cab-compressed",
117
+		"gb" => "application/chinese-gb",
118
+		"gba" => "application/octet-stream",
119
+		"gbc" => "application/octet-stream",
120
+		"jad" => "text/vnd.sun.j2me.app-descriptor",
121
+		"jar" => "application/java-archive",
122
+		"nes" => "application/octet-stream",
123
+		"rar" => "application/x-rar-compressed",
124
+		"sis" => "application/vnd.symbian.install",
125
+		"sisx" => "x-epoc/x-sisx-app",
126
+		"smc" => "application/octet-stream",
127
+		"smd" => "application/octet-stream",
128
+		"swf" => "application/x-shockwave-flash",
129
+		"zip" => "application/x-zip-compressed",
130
+		"wap" => "text/vnd.wap.wml wml", "mrp" => "application/mrp",
131
+		"wma" => "audio/x-ms-wma",
132
+		"lrc" => "application/lrc"
133
+	);
134 134
 
135
-    public static function getMimetype($ext)
136
-    {
137
-        $ext = strtolower($ext);
138
-        return (isset(self::$mime_types[$ext]) ? self::$mime_types[$ext] : 'application/octet-stream');
139
-    }
135
+	public static function getMimetype($ext)
136
+	{
137
+		$ext = strtolower($ext);
138
+		return (isset(self::$mime_types[$ext]) ? self::$mime_types[$ext] : 'application/octet-stream');
139
+	}
140 140
 }
Please login to merge, or discard this patch.
sdk/Utils/EncodeUtils.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -4,27 +4,27 @@
 block discarded – undo
4 4
 class EncodeUtils
5 5
 {
6 6
 
7
-    /*
7
+	/*
8 8
      * URL安全的Base64编码适用于以URL方式传递Base64编码结果的场景。
9 9
      * 该编码方式的基本过程是先将内容以Base64格式编码为字符串,
10 10
      * 然后检查该结果字符串,将字符串中的加号+换成中划线-,并且将斜杠/换成下划线_,同时尾部去除等号padding。
11 11
      */
12
-    public static function encodeWithURLSafeBase64($arg)
13
-    {
14
-        if ($arg === null || empty($arg)) {
15
-            return null;
16
-        }
17
-        $result = base64_encode($arg);
18
-        $result = str_replace(array('+', '/', '='), array('-', '_', ''), $result);
19
-        return $result;
20
-    }
12
+	public static function encodeWithURLSafeBase64($arg)
13
+	{
14
+		if ($arg === null || empty($arg)) {
15
+			return null;
16
+		}
17
+		$result = base64_encode($arg);
18
+		$result = str_replace(array('+', '/', '='), array('-', '_', ''), $result);
19
+		return $result;
20
+	}
21 21
 
22
-    public static function newEncodeWithUrlSafeBase64($arg)
23
-    {
24
-        if ($arg === null || empty($arg)) {
25
-            return null;
26
-        }
27
-        $result = preg_replace(array("/\r/", "/\n/"), "", rtrim(base64_encode($arg), '='));
28
-        return $result;
29
-    }
22
+	public static function newEncodeWithUrlSafeBase64($arg)
23
+	{
24
+		if ($arg === null || empty($arg)) {
25
+			return null;
26
+		}
27
+		$result = preg_replace(array("/\r/", "/\n/"), "", rtrim(base64_encode($arg), '='));
28
+		return $result;
29
+	}
30 30
 }
Please login to merge, or discard this patch.
sdk/Utils/MediaEncodeOption.php 2 patches
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -5,88 +5,88 @@
 block discarded – undo
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 .= '&notifyUrl=' . 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 .= '&notifyUrl=' . 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
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
56 56
             $httpBody .= '&notifyUrl=' . 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;
Please login to merge, or discard this patch.
sdk/Utils/UploadOption.php 2 patches
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -6,164 +6,164 @@
 block discarded – undo
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->getParasCommonBlockInit();
50
-            case UpOptionType::BLOCK_RUN_UPLOAD:
51
-                return $this->getParasBlockRun();
52
-            case UpOptionType::BLOCK_COMPLETE_UPLOAD:
53
-                return $this->getParasBlockComplete();
54
-            case UpOptionType::BLOCK_CANCEL_UPLOAD:
55
-                return $this->getParasBlockCancel();
56
-            default:
57
-                return null;
58
-        }
59
-    }
60
-    /** 构造 普通上传 或者 初始化分片上传 所需的参数 */
61
-    private function getParasCommonBlockInit()
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 getParasBlockRun()
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 getParasBlockComplete()
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 getParasBlockCancel()
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->getParasCommonBlockInit();
50
+			case UpOptionType::BLOCK_RUN_UPLOAD:
51
+				return $this->getParasBlockRun();
52
+			case UpOptionType::BLOCK_COMPLETE_UPLOAD:
53
+				return $this->getParasBlockComplete();
54
+			case UpOptionType::BLOCK_CANCEL_UPLOAD:
55
+				return $this->getParasBlockCancel();
56
+			default:
57
+				return null;
58
+		}
59
+	}
60
+	/** 构造 普通上传 或者 初始化分片上传 所需的参数 */
61
+	private function getParasCommonBlockInit()
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 getParasBlockRun()
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 getParasBlockComplete()
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 getParasBlockCancel()
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
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,34 +10,34 @@
 block discarded – undo
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请求体所需的参数*/
Please login to merge, or discard this patch.
sdk/Utils/MediaResOption.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -5,42 +5,42 @@
 block discarded – undo
5 5
 /**多媒体操作的输入输出资源信息。视频截图和视频转码都继承该类*/
6 6
 abstract class MediaResOption
7 7
 {
8
-    private $input;                  //输入的资源
9
-    private $output;                 //输出的资源
10
-    /**设置输入的文件。*/
11
-    public function setInputResource($namespace = null, $dir = null, $name = null)
12
-    {
13
-        $this->input = new ResourceInfo($namespace, $dir, $name);
14
-    }
15
-    /**设置输出的文件。*/
16
-    public function setOutputResource($namespace = null, $dir = null, $name = null)
17
-    {
18
-        $this->output = new ResourceInfo($namespace, $dir, $name);
19
-    }
20
-    /**检测参数选项是否合法*/
21
-    public function checkOptionParameters()
22
-    {
23
-        if (empty($this->input) || empty($this->output)) {
24
-            return array(false, "input or output resources is empty."); // 判断是否设置输入输出文件,或者转码模板
25
-        }
26
-        list($valid, $msg) = $this->input->checkResourceInfo(true, true); //检测输入的资源信息是否合法
27
-        if (!$valid) {
28
-            return array($valid, $msg);
29
-        }
30
-        list($valid, $msg) = $this->output->checkResourceInfo(true, true); //检测输入的资源信息是否合法
31
-        if (!$valid) {
32
-            return array($valid, $msg);
33
-        }
34
-        return array(true, null);
35
-    }
36
-    public function getInputResId()
37
-    {
38
-        return $this->input->buildResourceId();
39
-    }
40
-    public function getOutputResId()
41
-    {
42
-        return $this->output->buildResourceId();
43
-    }
44
-    /**得到属性的http请求体*/
45
-    abstract public function getOptionsHttpBody();
8
+	private $input;                  //输入的资源
9
+	private $output;                 //输出的资源
10
+	/**设置输入的文件。*/
11
+	public function setInputResource($namespace = null, $dir = null, $name = null)
12
+	{
13
+		$this->input = new ResourceInfo($namespace, $dir, $name);
14
+	}
15
+	/**设置输出的文件。*/
16
+	public function setOutputResource($namespace = null, $dir = null, $name = null)
17
+	{
18
+		$this->output = new ResourceInfo($namespace, $dir, $name);
19
+	}
20
+	/**检测参数选项是否合法*/
21
+	public function checkOptionParameters()
22
+	{
23
+		if (empty($this->input) || empty($this->output)) {
24
+			return array(false, "input or output resources is empty."); // 判断是否设置输入输出文件,或者转码模板
25
+		}
26
+		list($valid, $msg) = $this->input->checkResourceInfo(true, true); //检测输入的资源信息是否合法
27
+		if (!$valid) {
28
+			return array($valid, $msg);
29
+		}
30
+		list($valid, $msg) = $this->output->checkResourceInfo(true, true); //检测输入的资源信息是否合法
31
+		if (!$valid) {
32
+			return array($valid, $msg);
33
+		}
34
+		return array(true, null);
35
+	}
36
+	public function getInputResId()
37
+	{
38
+		return $this->input->buildResourceId();
39
+	}
40
+	public function getOutputResId()
41
+	{
42
+		return $this->output->buildResourceId();
43
+	}
44
+	/**得到属性的http请求体*/
45
+	abstract public function getOptionsHttpBody();
46 46
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@
 block discarded – undo
5 5
 /**多媒体操作的输入输出资源信息。视频截图和视频转码都继承该类*/
6 6
 abstract class MediaResOption
7 7
 {
8
-    private $input;                  //输入的资源
9
-    private $output;                 //输出的资源
8
+    private $input; //输入的资源
9
+    private $output; //输出的资源
10 10
     /**设置输入的文件。*/
11 11
     public function setInputResource($namespace = null, $dir = null, $name = null)
12 12
     {
Please login to merge, or discard this patch.
sdk/Utils/UpOptionType.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@
 block discarded – undo
8 8
  */
9 9
 class UpOptionType
10 10
 {
11
-    //下面的常量用于标识UploadOption对象适用的类型
12
-    const COMMON_UPLOAD_TYPE = 0;       //普通上传时的UploadOption类型
13
-    const BLOCK_INIT_UPLOAD = 1;        //分片初始化时的UploadOption类型
14
-    const BLOCK_RUN_UPLOAD = 2;         //分片上传过程中的UploadOption类型
15
-    const BLOCK_COMPLETE_UPLOAD = 3;    //分片上传完成时的UploadOption类型
16
-    const BLOCK_CANCEL_UPLOAD = 4;      //分片上传取消时的UploadOption类型
11
+	//下面的常量用于标识UploadOption对象适用的类型
12
+	const COMMON_UPLOAD_TYPE = 0;       //普通上传时的UploadOption类型
13
+	const BLOCK_INIT_UPLOAD = 1;        //分片初始化时的UploadOption类型
14
+	const BLOCK_RUN_UPLOAD = 2;         //分片上传过程中的UploadOption类型
15
+	const BLOCK_COMPLETE_UPLOAD = 3;    //分片上传完成时的UploadOption类型
16
+	const BLOCK_CANCEL_UPLOAD = 4;      //分片上传取消时的UploadOption类型
17 17
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@
 block discarded – undo
9 9
 class UpOptionType
10 10
 {
11 11
     //下面的常量用于标识UploadOption对象适用的类型
12
-    const COMMON_UPLOAD_TYPE = 0;       //普通上传时的UploadOption类型
13
-    const BLOCK_INIT_UPLOAD = 1;        //分片初始化时的UploadOption类型
14
-    const BLOCK_RUN_UPLOAD = 2;         //分片上传过程中的UploadOption类型
15
-    const BLOCK_COMPLETE_UPLOAD = 3;    //分片上传完成时的UploadOption类型
16
-    const BLOCK_CANCEL_UPLOAD = 4;      //分片上传取消时的UploadOption类型
12
+    const COMMON_UPLOAD_TYPE = 0; //普通上传时的UploadOption类型
13
+    const BLOCK_INIT_UPLOAD = 1; //分片初始化时的UploadOption类型
14
+    const BLOCK_RUN_UPLOAD = 2; //分片上传过程中的UploadOption类型
15
+    const BLOCK_COMPLETE_UPLOAD = 3; //分片上传完成时的UploadOption类型
16
+    const BLOCK_CANCEL_UPLOAD = 4; //分片上传取消时的UploadOption类型
17 17
 }
Please login to merge, or discard this patch.
sdk/Core/ManageClient.php 2 patches
Indentation   +432 added lines, -432 removed lines patch added patch discarded remove patch
@@ -10,461 +10,461 @@
 block discarded – undo
10 10
 
11 11
 class ManageClient
12 12
 {
13
-    private $manage_host;
14
-    private $ak;
15
-    private $sk;
16
-    private $type;
17
-    public function __construct($ak, $sk, $type = Conf::TYPE_TOP)
18
-    {
19
-        $this->ak = $ak;
20
-        $this->sk = $sk;
21
-        $this->type = $type;
22
-        $this->manage_host = Conf::MANAGE_HOST_MEDIA;
23
-    }
13
+	private $manage_host;
14
+	private $ak;
15
+	private $sk;
16
+	private $type;
17
+	public function __construct($ak, $sk, $type = Conf::TYPE_TOP)
18
+	{
19
+		$this->ak = $ak;
20
+		$this->sk = $sk;
21
+		$this->type = $type;
22
+		$this->manage_host = Conf::MANAGE_HOST_MEDIA;
23
+	}
24 24
 
25
-    /**
26
-     * 文件是否存在
27
-     * @param string $namespace 空间名,必须
28
-     * @param string $dir 路径
29
-     * @param string $filename 文件名
30
-     * @return array
31
-     */
32
-    public function existsFile($namespace, $dir, $filename)
33
-    {
34
-        $resourceInfo = new ResourceInfo($namespace, $dir, $filename);
35
-        list($isValid, $message) = $resourceInfo->checkResourceInfo(true, true);
36
-        if (!$isValid) {
37
-            return $this->errorResponse("InvalidArgument", $message);
38
-        }
39
-        $resourceId = $resourceInfo->buildResourceId(); //得到资源ID
40
-        $uri = '/' . Conf::MANAGE_API_VERSION . '/files/' . $resourceId . '/exist';
41
-        return $this->sendRequest('GET', $uri);
42
-    }
25
+	/**
26
+	 * 文件是否存在
27
+	 * @param string $namespace 空间名,必须
28
+	 * @param string $dir 路径
29
+	 * @param string $filename 文件名
30
+	 * @return array
31
+	 */
32
+	public function existsFile($namespace, $dir, $filename)
33
+	{
34
+		$resourceInfo = new ResourceInfo($namespace, $dir, $filename);
35
+		list($isValid, $message) = $resourceInfo->checkResourceInfo(true, true);
36
+		if (!$isValid) {
37
+			return $this->errorResponse("InvalidArgument", $message);
38
+		}
39
+		$resourceId = $resourceInfo->buildResourceId(); //得到资源ID
40
+		$uri = '/' . Conf::MANAGE_API_VERSION . '/files/' . $resourceId . '/exist';
41
+		return $this->sendRequest('GET', $uri);
42
+	}
43 43
 
44
-    /**
45
-     * 获取文件的元信息(meta信息)
46
-     * @param string $namespace 空间名,必须
47
-     * @param string $dir 路径
48
-     * @param string $filename 文件名
49
-     * @return array
50
-     */
51
-    public function getFileInfo($namespace, $dir, $filename)
52
-    {
53
-        $resourceInfo = new ResourceInfo($namespace, $dir, $filename);
54
-        list($isValid, $message) = $resourceInfo->checkResourceInfo(true, true);
55
-        if (!$isValid) {
56
-            return $this->errorResponse("InvalidArgument", $message);
57
-        }
58
-        $resourceId = $resourceInfo->buildResourceId(); //得到资源ID
59
-        $uri = '/' . Conf::MANAGE_API_VERSION . '/files/' . $resourceId;
60
-        return $this->sendRequest('GET', $uri);
61
-    }
44
+	/**
45
+	 * 获取文件的元信息(meta信息)
46
+	 * @param string $namespace 空间名,必须
47
+	 * @param string $dir 路径
48
+	 * @param string $filename 文件名
49
+	 * @return array
50
+	 */
51
+	public function getFileInfo($namespace, $dir, $filename)
52
+	{
53
+		$resourceInfo = new ResourceInfo($namespace, $dir, $filename);
54
+		list($isValid, $message) = $resourceInfo->checkResourceInfo(true, true);
55
+		if (!$isValid) {
56
+			return $this->errorResponse("InvalidArgument", $message);
57
+		}
58
+		$resourceId = $resourceInfo->buildResourceId(); //得到资源ID
59
+		$uri = '/' . Conf::MANAGE_API_VERSION . '/files/' . $resourceId;
60
+		return $this->sendRequest('GET', $uri);
61
+	}
62 62
 
63
-    /**
64
-     * 重命名文件
65
-     * @param string $namespace 空间名,必须
66
-     * @param string $dir 路径
67
-     * @param string $filename 文件名
68
-     * @param string $newDir 新的路径
69
-     * @param string $newName 新的文件名
70
-     * @return array
71
-     */
72
-    public function renameFile($namespace, $dir, $filename, $newDir, $newName)
73
-    {
74
-        $resourceInfo = new ResourceInfo($namespace, $dir, $filename); //老的资源
75
-        list($isValid, $message) = $resourceInfo->checkResourceInfo(true, true);
76
-        if (!$isValid) {
77
-            return $this->errorResponse("InvalidArgument", $message);
78
-        }
79
-        $newResourceInfo = new ResourceInfo($namespace, $newDir, $newName); //新的资源
80
-        list($isValid, $message) = $newResourceInfo->checkResourceInfo(true, true);
81
-        if (!$isValid) {
82
-            return $this->errorResponse("InvalidArgument", $message);
83
-        }
84
-        $resourceId = $resourceInfo->buildResourceId(); //老资源ID
85
-        $newResourceId = $newResourceInfo->buildResourceId(); //新资源ID
86
-        $uri = '/' . Conf::MANAGE_API_VERSION . '/files/' . $resourceId . "/rename/" . $newResourceId;
87
-        return $this->sendRequest('POST', $uri);
88
-    }
63
+	/**
64
+	 * 重命名文件
65
+	 * @param string $namespace 空间名,必须
66
+	 * @param string $dir 路径
67
+	 * @param string $filename 文件名
68
+	 * @param string $newDir 新的路径
69
+	 * @param string $newName 新的文件名
70
+	 * @return array
71
+	 */
72
+	public function renameFile($namespace, $dir, $filename, $newDir, $newName)
73
+	{
74
+		$resourceInfo = new ResourceInfo($namespace, $dir, $filename); //老的资源
75
+		list($isValid, $message) = $resourceInfo->checkResourceInfo(true, true);
76
+		if (!$isValid) {
77
+			return $this->errorResponse("InvalidArgument", $message);
78
+		}
79
+		$newResourceInfo = new ResourceInfo($namespace, $newDir, $newName); //新的资源
80
+		list($isValid, $message) = $newResourceInfo->checkResourceInfo(true, true);
81
+		if (!$isValid) {
82
+			return $this->errorResponse("InvalidArgument", $message);
83
+		}
84
+		$resourceId = $resourceInfo->buildResourceId(); //老资源ID
85
+		$newResourceId = $newResourceInfo->buildResourceId(); //新资源ID
86
+		$uri = '/' . Conf::MANAGE_API_VERSION . '/files/' . $resourceId . "/rename/" . $newResourceId;
87
+		return $this->sendRequest('POST', $uri);
88
+	}
89 89
 
90
-    /**
91
-     * 获取指定目录下的文件列表
92
-     * @param string $namespace 空间名,必须
93
-     * @param string $dir 路径
94
-     * @param number $page 页数
95
-     * @param number $pageSize 每页显示的记录数
96
-     */
97
-    public function listFiles($namespace, $dir, $page = 1, $pageSize = 100)
98
-    {
99
-        $manageOption = new ManageOption($namespace);
100
-        $manageOption->setDir($dir)->setCurrentPage($page)->setPageSize($pageSize);
101
-        list($isValid, $message) = $manageOption->checkResourceInfo(true);
102
-        if ($page <= 0 || $pageSize <= 0) {
103
-            $isValid = false;
104
-            $message = "Invalid parameters page or pageSize";
105
-        }
106
-        if (!$isValid) {
107
-            return $this->errorResponse("InvalidArgument", $message);
108
-        }
109
-        $queryParas = $manageOption->buildListFilesParas(); //查询query参数
110
-        $uri = '/' . Conf::MANAGE_API_VERSION . '/files?' . $queryParas;
111
-        return $this->sendRequest('GET', $uri);
112
-    }
90
+	/**
91
+	 * 获取指定目录下的文件列表
92
+	 * @param string $namespace 空间名,必须
93
+	 * @param string $dir 路径
94
+	 * @param number $page 页数
95
+	 * @param number $pageSize 每页显示的记录数
96
+	 */
97
+	public function listFiles($namespace, $dir, $page = 1, $pageSize = 100)
98
+	{
99
+		$manageOption = new ManageOption($namespace);
100
+		$manageOption->setDir($dir)->setCurrentPage($page)->setPageSize($pageSize);
101
+		list($isValid, $message) = $manageOption->checkResourceInfo(true);
102
+		if ($page <= 0 || $pageSize <= 0) {
103
+			$isValid = false;
104
+			$message = "Invalid parameters page or pageSize";
105
+		}
106
+		if (!$isValid) {
107
+			return $this->errorResponse("InvalidArgument", $message);
108
+		}
109
+		$queryParas = $manageOption->buildListFilesParas(); //查询query参数
110
+		$uri = '/' . Conf::MANAGE_API_VERSION . '/files?' . $queryParas;
111
+		return $this->sendRequest('GET', $uri);
112
+	}
113 113
 
114
-    /**
115
-     * 删除文件
116
-     * @param string $namespace 空间名,必须
117
-     * @param string $dir 路径
118
-     * @param string $filename 文件名
119
-     * @return array
120
-     */
121
-    public function deleteFile($namespace, $dir, $filename)
122
-    {
123
-        $resourceInfo = new ResourceInfo($namespace, $dir, $filename);
124
-        list($isValid, $message) = $resourceInfo->checkResourceInfo(true, true);
125
-        if (!$isValid) {
126
-            return $this->errorResponse("InvalidArgument", $message);
127
-        }
128
-        $resourceId = $resourceInfo->buildResourceId(); //得到资源ID
129
-        $uri = '/' . Conf::MANAGE_API_VERSION . '/files/' . $resourceId;
130
-        return $this->sendRequest('DELETE', $uri);
131
-    }
114
+	/**
115
+	 * 删除文件
116
+	 * @param string $namespace 空间名,必须
117
+	 * @param string $dir 路径
118
+	 * @param string $filename 文件名
119
+	 * @return array
120
+	 */
121
+	public function deleteFile($namespace, $dir, $filename)
122
+	{
123
+		$resourceInfo = new ResourceInfo($namespace, $dir, $filename);
124
+		list($isValid, $message) = $resourceInfo->checkResourceInfo(true, true);
125
+		if (!$isValid) {
126
+			return $this->errorResponse("InvalidArgument", $message);
127
+		}
128
+		$resourceId = $resourceInfo->buildResourceId(); //得到资源ID
129
+		$uri = '/' . Conf::MANAGE_API_VERSION . '/files/' . $resourceId;
130
+		return $this->sendRequest('DELETE', $uri);
131
+	}
132 132
 
133
-    /**
134
-     * 文件夹是否存在
135
-     * @param string $namespace 空间名,必须
136
-     * @param string $dir 路径,即文件夹
137
-     * @return array
138
-     */
139
-    public function existsFolder($namespace, $dir)
140
-    {
141
-        if (empty($namespace) || empty($dir)) {
142
-            return $this->errorResponse("InvalidArgument", "namespace or dir is empty");
143
-        }
144
-        if (strpos($dir, '/') !== 0) {
145
-            $dir = '/' . $dir;
146
-        }
147
-        $resourceInfo = new ResourceInfo($namespace, $dir);
148
-        $resourceId = $resourceInfo->buildResourceId(); //得到资源ID
149
-        $uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId . '/exist';
150
-        return $this->sendRequest('GET', $uri);
151
-    }
133
+	/**
134
+	 * 文件夹是否存在
135
+	 * @param string $namespace 空间名,必须
136
+	 * @param string $dir 路径,即文件夹
137
+	 * @return array
138
+	 */
139
+	public function existsFolder($namespace, $dir)
140
+	{
141
+		if (empty($namespace) || empty($dir)) {
142
+			return $this->errorResponse("InvalidArgument", "namespace or dir is empty");
143
+		}
144
+		if (strpos($dir, '/') !== 0) {
145
+			$dir = '/' . $dir;
146
+		}
147
+		$resourceInfo = new ResourceInfo($namespace, $dir);
148
+		$resourceId = $resourceInfo->buildResourceId(); //得到资源ID
149
+		$uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId . '/exist';
150
+		return $this->sendRequest('GET', $uri);
151
+	}
152 152
 
153
-    /**
154
-     * 创建文件夹
155
-     * @param string $namespace 空间名,必须
156
-     * @param string $dir 路径,即文件夹
157
-     * @return array
158
-     */
159
-    public function createDir($namespace, $dir)
160
-    {
161
-        if (empty($namespace) || empty($dir)) {
162
-            return $this->errorResponse("InvalidArgument", "namespace or dir is empty");
163
-        }
164
-        if (strpos($dir, '/') !== 0) {
165
-            $dir = '/' . $dir;
166
-        }
167
-        $resourceInfo = new ResourceInfo($namespace, $dir);
168
-        $resourceId = $resourceInfo->buildResourceId(); //得到资源ID
169
-        $uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId;
170
-        return $this->sendRequest('POST', $uri);
171
-    }
153
+	/**
154
+	 * 创建文件夹
155
+	 * @param string $namespace 空间名,必须
156
+	 * @param string $dir 路径,即文件夹
157
+	 * @return array
158
+	 */
159
+	public function createDir($namespace, $dir)
160
+	{
161
+		if (empty($namespace) || empty($dir)) {
162
+			return $this->errorResponse("InvalidArgument", "namespace or dir is empty");
163
+		}
164
+		if (strpos($dir, '/') !== 0) {
165
+			$dir = '/' . $dir;
166
+		}
167
+		$resourceInfo = new ResourceInfo($namespace, $dir);
168
+		$resourceId = $resourceInfo->buildResourceId(); //得到资源ID
169
+		$uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId;
170
+		return $this->sendRequest('POST', $uri);
171
+	}
172 172
 
173
-    /**
174
-     * 获取指定目录下的文件夹列表
175
-     * @param string $namespace 空间名,必须
176
-     * @param string $dir 路径,指定目录
177
-     * @param number $page 页数
178
-     * @param number $pageSize 每页显示的记录数
179
-     */
180
-    public function listDirs($namespace, $dir, $page = 1, $pageSize = 100)
181
-    {
182
-        $manageOption = new ManageOption($namespace);
183
-        $manageOption->setDir($dir)->setCurrentPage($page)->setPageSize($pageSize);
184
-        list($isValid, $message) = $manageOption->checkResourceInfo(true);
185
-        if ($page <= 0 || $pageSize <= 0) {
186
-            $isValid = false;
187
-            $message = "Invalid parameters page or pageSize";
188
-        }
189
-        if (!$isValid) {
190
-            return $this->errorResponse("InvalidArgument", $message);
191
-        }
192
-        $queryParas = $manageOption->buildListFilesParas(); //查询query参数
193
-        $uri = '/' . Conf::MANAGE_API_VERSION . '/folders?' . $queryParas;
194
-        return $this->sendRequest('GET', $uri);
195
-    }
173
+	/**
174
+	 * 获取指定目录下的文件夹列表
175
+	 * @param string $namespace 空间名,必须
176
+	 * @param string $dir 路径,指定目录
177
+	 * @param number $page 页数
178
+	 * @param number $pageSize 每页显示的记录数
179
+	 */
180
+	public function listDirs($namespace, $dir, $page = 1, $pageSize = 100)
181
+	{
182
+		$manageOption = new ManageOption($namespace);
183
+		$manageOption->setDir($dir)->setCurrentPage($page)->setPageSize($pageSize);
184
+		list($isValid, $message) = $manageOption->checkResourceInfo(true);
185
+		if ($page <= 0 || $pageSize <= 0) {
186
+			$isValid = false;
187
+			$message = "Invalid parameters page or pageSize";
188
+		}
189
+		if (!$isValid) {
190
+			return $this->errorResponse("InvalidArgument", $message);
191
+		}
192
+		$queryParas = $manageOption->buildListFilesParas(); //查询query参数
193
+		$uri = '/' . Conf::MANAGE_API_VERSION . '/folders?' . $queryParas;
194
+		return $this->sendRequest('GET', $uri);
195
+	}
196 196
 
197
-    /**
198
-     * 删除文件夹
199
-     * @param string $namespace 空间名,必须
200
-     * @param string $dir 路径,即文件夹
201
-     * @return array
202
-     */
203
-    public function deleteDir($namespace, $dir)
204
-    {
205
-        if (empty($namespace) || empty($dir)) {
206
-            return $this->errorResponse("InvalidArgument", "namespace or dir is empty");
207
-        }
208
-        if (strpos($dir, '/') !== 0) {
209
-            $dir = '/' . $dir;
210
-        }
211
-        $resourceInfo = new ResourceInfo($namespace, $dir);
212
-        $resourceId = $resourceInfo->buildResourceId(); //得到资源ID
213
-        $uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId;
214
-        return $this->sendRequest('DELETE', $uri);
215
-    }
216
-    /*######################################华丽的分界线#######################################*/
217
-    /*#######################上面是文件或文件夹的管理,下面是特色服务接口########################*/
218
-    /*########################################################################################*/
219
-    /**黄图扫描接口
197
+	/**
198
+	 * 删除文件夹
199
+	 * @param string $namespace 空间名,必须
200
+	 * @param string $dir 路径,即文件夹
201
+	 * @return array
202
+	 */
203
+	public function deleteDir($namespace, $dir)
204
+	{
205
+		if (empty($namespace) || empty($dir)) {
206
+			return $this->errorResponse("InvalidArgument", "namespace or dir is empty");
207
+		}
208
+		if (strpos($dir, '/') !== 0) {
209
+			$dir = '/' . $dir;
210
+		}
211
+		$resourceInfo = new ResourceInfo($namespace, $dir);
212
+		$resourceId = $resourceInfo->buildResourceId(); //得到资源ID
213
+		$uri = '/' . Conf::MANAGE_API_VERSION . '/folders/' . $resourceId;
214
+		return $this->sendRequest('DELETE', $uri);
215
+	}
216
+	/*######################################华丽的分界线#######################################*/
217
+	/*#######################上面是文件或文件夹的管理,下面是特色服务接口########################*/
218
+	/*########################################################################################*/
219
+	/**黄图扫描接口
220 220
      * @param ManageOption $resInfos 待扫描图片资源
221 221
      * @return array
222 222
      */
223
-    public function scanPorn(ManageOption $resInfos)
224
-    {
225
-        $uri = '/' . Conf::SCAN_PORN_VERSION . '/scanPorn';
226
-        list($isValid, $message, $bodyArray) = $resInfos->checkFilesAndUrls(); //检测并得到黄图扫描所需参数
227
-        if (!$isValid) {
228
-            return $this->errorResponse("InvalidArgument", $message);
229
-        }
230
-        $httpBody = $this->createHttpBody($bodyArray); //http body字符串信息
231
-        return $this->sendRequest('POST', $uri, $httpBody);
232
-    }
223
+	public function scanPorn(ManageOption $resInfos)
224
+	{
225
+		$uri = '/' . Conf::SCAN_PORN_VERSION . '/scanPorn';
226
+		list($isValid, $message, $bodyArray) = $resInfos->checkFilesAndUrls(); //检测并得到黄图扫描所需参数
227
+		if (!$isValid) {
228
+			return $this->errorResponse("InvalidArgument", $message);
229
+		}
230
+		$httpBody = $this->createHttpBody($bodyArray); //http body字符串信息
231
+		return $this->sendRequest('POST', $uri, $httpBody);
232
+	}
233 233
 
234
-    /**
235
-     * 鉴黄反馈feedback接口
236
-     * @param ManageOption $pornFbInfos 反馈信息
237
-     * @return array
238
-     */
239
-    public function pornFeedback(ManageOption $pornFbInfos)
240
-    {
241
-        $uri = '/' . Conf::SCAN_PORN_VERSION . '/feedback';
242
-        list($isValid, $message, $httpBody) = $pornFbInfos->checkPornFeedbackInfos();
243
-        if (!$isValid) {
244
-            return $this->errorResponse("InvalidArgument", $message);
245
-        }
246
-        return $this->sendRequest('POST', $uri, $httpBody);
247
-    }
234
+	/**
235
+	 * 鉴黄反馈feedback接口
236
+	 * @param ManageOption $pornFbInfos 反馈信息
237
+	 * @return array
238
+	 */
239
+	public function pornFeedback(ManageOption $pornFbInfos)
240
+	{
241
+		$uri = '/' . Conf::SCAN_PORN_VERSION . '/feedback';
242
+		list($isValid, $message, $httpBody) = $pornFbInfos->checkPornFeedbackInfos();
243
+		if (!$isValid) {
244
+			return $this->errorResponse("InvalidArgument", $message);
245
+		}
246
+		return $this->sendRequest('POST', $uri, $httpBody);
247
+	}
248 248
 
249
-    /**
250
-     * 多媒体(音视频)转码服务接口
251
-     * @param MediaResOption $encodeOption 转码参数选项
252
-     * @return array
253
-     */
254
-    public function mediaEncode(MediaResOption $encodeOption)
255
-    {
256
-        $uri = '/' . Conf::MEDIA_ENCODE_VERSION . '/mediaEncode';
257
-        list($isValid, $message, $httpBody) = $encodeOption->checkOptionParameters();
258
-        if (!$isValid) {
259
-            return $this->errorResponse("InvalidArgument", $message);
260
-        }
261
-        return $this->sendRequest('POST', $uri, $httpBody);
262
-    }
249
+	/**
250
+	 * 多媒体(音视频)转码服务接口
251
+	 * @param MediaResOption $encodeOption 转码参数选项
252
+	 * @return array
253
+	 */
254
+	public function mediaEncode(MediaResOption $encodeOption)
255
+	{
256
+		$uri = '/' . Conf::MEDIA_ENCODE_VERSION . '/mediaEncode';
257
+		list($isValid, $message, $httpBody) = $encodeOption->checkOptionParameters();
258
+		if (!$isValid) {
259
+			return $this->errorResponse("InvalidArgument", $message);
260
+		}
261
+		return $this->sendRequest('POST', $uri, $httpBody);
262
+	}
263 263
 
264
-    /**
265
-     * 多媒体转码任务查询接口
266
-     * @param string $taskId 转码任务ID
267
-     */
268
-    public function mediaEncodeQuery($taskId)
269
-    {
270
-        if (empty($taskId)) {
271
-            return $this->errorResponse("InvalidArgument", "taskId is empty");
272
-        }
273
-        $uri = '/' . Conf::MEDIA_ENCODE_VERSION . '/mediaEncodeResult/' . $taskId;
274
-        return $this->sendRequest('GET', $uri);
275
-    }
264
+	/**
265
+	 * 多媒体转码任务查询接口
266
+	 * @param string $taskId 转码任务ID
267
+	 */
268
+	public function mediaEncodeQuery($taskId)
269
+	{
270
+		if (empty($taskId)) {
271
+			return $this->errorResponse("InvalidArgument", "taskId is empty");
272
+		}
273
+		$uri = '/' . Conf::MEDIA_ENCODE_VERSION . '/mediaEncodeResult/' . $taskId;
274
+		return $this->sendRequest('GET', $uri);
275
+	}
276 276
 
277
-    /**
278
-     * 视频截图接口
279
-     * @param MediaResOption $snapshotOption 截图参数选项
280
-     * @return array
281
-     */
282
-    public function videoSnapshot(MediaResOption $snapshotOption)
283
-    {
284
-        $uri = '/' . Conf::MANAGE_API_VERSION . '/snapshot';
285
-        list($isValid, $message, $httpBody) = $snapshotOption->checkOptionParameters();
286
-        if (!$isValid) {
287
-            return $this->errorResponse("InvalidArgument", $message);
288
-        }
289
-        return $this->sendRequest('POST', $uri, $httpBody);
290
-    }
277
+	/**
278
+	 * 视频截图接口
279
+	 * @param MediaResOption $snapshotOption 截图参数选项
280
+	 * @return array
281
+	 */
282
+	public function videoSnapshot(MediaResOption $snapshotOption)
283
+	{
284
+		$uri = '/' . Conf::MANAGE_API_VERSION . '/snapshot';
285
+		list($isValid, $message, $httpBody) = $snapshotOption->checkOptionParameters();
286
+		if (!$isValid) {
287
+			return $this->errorResponse("InvalidArgument", $message);
288
+		}
289
+		return $this->sendRequest('POST', $uri, $httpBody);
290
+	}
291 291
 
292
-    /**
293
-     * 视频截图结果查询接口
294
-     * @param string $taskId 转码任务ID
295
-     */
296
-    public function vSnapshotQuery($taskId)
297
-    {
298
-        if (empty($taskId)) {
299
-            return $this->errorResponse("InvalidArgument", "taskId is empty");
300
-        }
301
-        $uri = '/' . Conf::MANAGE_API_VERSION . '/snapshotResult/' . $taskId;
302
-        return $this->sendRequest('GET', $uri);
303
-    }
292
+	/**
293
+	 * 视频截图结果查询接口
294
+	 * @param string $taskId 转码任务ID
295
+	 */
296
+	public function vSnapshotQuery($taskId)
297
+	{
298
+		if (empty($taskId)) {
299
+			return $this->errorResponse("InvalidArgument", "taskId is empty");
300
+		}
301
+		$uri = '/' . Conf::MANAGE_API_VERSION . '/snapshotResult/' . $taskId;
302
+		return $this->sendRequest('GET', $uri);
303
+	}
304 304
 
305
-    /**
306
-     *
307
-     * 广告图扫描接口(beta)
308
-     * @param ManageOption $resInfos 待扫描图片资源
309
-     * @return array
310
-     */
311
-    public function scanAdvertising(ManageOption $resInfos)
312
-    {
313
-        $uri = '/3.1/scanAdvertising';
314
-        list($isValid, $message, $bodyArray) = $resInfos->checkFilesAndUrls(); //检测并得到广告图图扫描所需参数
315
-        if (!$isValid) {
316
-            return $this->errorResponse("InvalidArgument", $message);
317
-        }
318
-        $httpBody = $this->createHttpBody($bodyArray); //http body字符串信息
319
-        return $this->sendRequest('POST', $uri, $httpBody);
320
-    }
305
+	/**
306
+	 *
307
+	 * 广告图扫描接口(beta)
308
+	 * @param ManageOption $resInfos 待扫描图片资源
309
+	 * @return array
310
+	 */
311
+	public function scanAdvertising(ManageOption $resInfos)
312
+	{
313
+		$uri = '/3.1/scanAdvertising';
314
+		list($isValid, $message, $bodyArray) = $resInfos->checkFilesAndUrls(); //检测并得到广告图图扫描所需参数
315
+		if (!$isValid) {
316
+			return $this->errorResponse("InvalidArgument", $message);
317
+		}
318
+		$httpBody = $this->createHttpBody($bodyArray); //http body字符串信息
319
+		return $this->sendRequest('POST', $uri, $httpBody);
320
+	}
321 321
 
322
-    /**
323
-     * 调用curl利用http上传数据
324
-     * @param string $method
325
-     * @param string $uri
326
-     * @param array $bodyArray
327
-     * @param array $headers
328
-     * @return array (isSuccess, ...)
329
-     */
330
-    protected function sendRequest($method, $uri, $httpBody = null, $headers = null)
331
-    {
332
-        $success = false;
333
-        $result = null;
334
-        //构建Http请求头
335
-        $_headers = array('Expect:');
336
-        $date = $this->currentMilliSecond(); //得到当前的时间戳,毫秒
337
-        array_push($_headers, "Date: {$date}");
338
-        $authorization = $this->getAuthorization($uri, $date, $httpBody);  //Http的Body需要加入管理鉴权
339
-        array_push($_headers, "Authorization: {$authorization}");
340
-        array_push($_headers, "User-Agent: {$this->getUserAgent()}");
341
-        if (!is_null($headers) && is_array($headers)) {
342
-            foreach ($headers as $k => $v) {
343
-                array_push($_headers, "{$k}: {$v}");
344
-            }
345
-        }
346
-        $url = $this->getManageUrl($uri); //根据管理接口uri拼接成URL
347
-        $ch = curl_init($url);
348
-        try {
349
-            //构建http请求体,并设置header部分属性
350
-            $length = 0;
351
-            if (!empty($httpBody)) {
352
-                $length = @strlen($httpBody);
353
-                curl_setopt($ch, CURLOPT_POSTFIELDS, $httpBody);
354
-                array_push($_headers, "Content-Type: application/x-www-form-urlencoded");
355
-            }
356
-            array_push($_headers, "Content-Length: {$length}");
357
-            curl_setopt($ch, CURLOPT_HEADER, 1);                            //设置头部
358
-            curl_setopt($ch, CURLOPT_HTTPHEADER, $_headers);                //请求头
359
-            curl_setopt($ch, CURLOPT_TIMEOUT, Conf::HTTP_TIMEOUT);      //超时时长
360
-            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);               //连接超时时长
361
-            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //成功,只返回结果,不自动输出任何内容。如果失败返回FALSE
362
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
363
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);           //自定义请求
364
-            //设置请求方式(GET或POST等)
365
-            if ($method == 'PUT' || $method == 'POST') {
366
-                curl_setopt($ch, CURLOPT_POST, 1);
367
-            } else {
368
-                curl_setopt($ch, CURLOPT_POST, 0);
369
-            }
370
-            //执行请求,然后获取服务端返回
371
-            $response = curl_exec($ch);
372
-            if ($response == false) {
373
-                $result = $this->errorResponse("curl error", "curl request failed");
374
-                $result['errno'] = curl_errno($ch); //错误码
375
-            } else {
376
-                //解析返回结果,并判断是否上传成功
377
-                $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
378
-                $success = ($http_code == 200) ? true : false;                  //判断是否上传成功
379
-                $resStr = explode("\r\n\r\n", $response);
380
-                $resBody = isset($resStr[1]) ? $resStr[1] : '';
381
-                $resArray = json_decode($resBody, true);                        //解析得到结果
382
-                $result = (empty($resArray)) ? array() : $resArray;
383
-            }
384
-        } catch (Exception $e) {
385
-            $success = false;
386
-            $result = $this->errorResponse("HTTPRequestException#" . $e->getCode(), $e->getMessage());
387
-        }
388
-        curl_close($ch); //PHP5.3中不支持finally关键字。因此,为了兼容,这里取消finally
389
-        $result['isSuccess'] = $success;
390
-        return $result;
391
-    }
322
+	/**
323
+	 * 调用curl利用http上传数据
324
+	 * @param string $method
325
+	 * @param string $uri
326
+	 * @param array $bodyArray
327
+	 * @param array $headers
328
+	 * @return array (isSuccess, ...)
329
+	 */
330
+	protected function sendRequest($method, $uri, $httpBody = null, $headers = null)
331
+	{
332
+		$success = false;
333
+		$result = null;
334
+		//构建Http请求头
335
+		$_headers = array('Expect:');
336
+		$date = $this->currentMilliSecond(); //得到当前的时间戳,毫秒
337
+		array_push($_headers, "Date: {$date}");
338
+		$authorization = $this->getAuthorization($uri, $date, $httpBody);  //Http的Body需要加入管理鉴权
339
+		array_push($_headers, "Authorization: {$authorization}");
340
+		array_push($_headers, "User-Agent: {$this->getUserAgent()}");
341
+		if (!is_null($headers) && is_array($headers)) {
342
+			foreach ($headers as $k => $v) {
343
+				array_push($_headers, "{$k}: {$v}");
344
+			}
345
+		}
346
+		$url = $this->getManageUrl($uri); //根据管理接口uri拼接成URL
347
+		$ch = curl_init($url);
348
+		try {
349
+			//构建http请求体,并设置header部分属性
350
+			$length = 0;
351
+			if (!empty($httpBody)) {
352
+				$length = @strlen($httpBody);
353
+				curl_setopt($ch, CURLOPT_POSTFIELDS, $httpBody);
354
+				array_push($_headers, "Content-Type: application/x-www-form-urlencoded");
355
+			}
356
+			array_push($_headers, "Content-Length: {$length}");
357
+			curl_setopt($ch, CURLOPT_HEADER, 1);                            //设置头部
358
+			curl_setopt($ch, CURLOPT_HTTPHEADER, $_headers);                //请求头
359
+			curl_setopt($ch, CURLOPT_TIMEOUT, Conf::HTTP_TIMEOUT);      //超时时长
360
+			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);               //连接超时时长
361
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //成功,只返回结果,不自动输出任何内容。如果失败返回FALSE
362
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
363
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);           //自定义请求
364
+			//设置请求方式(GET或POST等)
365
+			if ($method == 'PUT' || $method == 'POST') {
366
+				curl_setopt($ch, CURLOPT_POST, 1);
367
+			} else {
368
+				curl_setopt($ch, CURLOPT_POST, 0);
369
+			}
370
+			//执行请求,然后获取服务端返回
371
+			$response = curl_exec($ch);
372
+			if ($response == false) {
373
+				$result = $this->errorResponse("curl error", "curl request failed");
374
+				$result['errno'] = curl_errno($ch); //错误码
375
+			} else {
376
+				//解析返回结果,并判断是否上传成功
377
+				$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
378
+				$success = ($http_code == 200) ? true : false;                  //判断是否上传成功
379
+				$resStr = explode("\r\n\r\n", $response);
380
+				$resBody = isset($resStr[1]) ? $resStr[1] : '';
381
+				$resArray = json_decode($resBody, true);                        //解析得到结果
382
+				$result = (empty($resArray)) ? array() : $resArray;
383
+			}
384
+		} catch (Exception $e) {
385
+			$success = false;
386
+			$result = $this->errorResponse("HTTPRequestException#" . $e->getCode(), $e->getMessage());
387
+		}
388
+		curl_close($ch); //PHP5.3中不支持finally关键字。因此,为了兼容,这里取消finally
389
+		$result['isSuccess'] = $success;
390
+		return $result;
391
+	}
392 392
 
393
-    /**
394
-     * 根据$bodyArray构建http请求体。多个字段之间用&号分割
395
-     */
396
-    protected function createHttpBody($bodyArray)
397
-    {
398
-        $bodyStr = '';
399
-        foreach ($bodyArray as $key => $value) {
400
-            $bodyStr .= (empty($bodyStr) ? null : '&'); //添加分隔符
401
-            $bodyStr .= "{$key}=" . urlencode($value);
402
-        }
403
-        return $bodyStr;
404
-    }
393
+	/**
394
+	 * 根据$bodyArray构建http请求体。多个字段之间用&号分割
395
+	 */
396
+	protected function createHttpBody($bodyArray)
397
+	{
398
+		$bodyStr = '';
399
+		foreach ($bodyArray as $key => $value) {
400
+			$bodyStr .= (empty($bodyStr) ? null : '&'); //添加分隔符
401
+			$bodyStr .= "{$key}=" . urlencode($value);
402
+		}
403
+		return $bodyStr;
404
+	}
405 405
 
406
-    /**
407
-     * UserAgent用户代理
408
-     */
409
-    protected function getUserAgent()
410
-    {
411
-        if ($this->type == "TOP") {
412
-            return "ALIMEDIASDK_PHP_TAE/" . Conf::SDK_VERSION;
413
-        } else {
414
-            return "ALIMEDIASDK_PHP_CLOUD/" . Conf::SDK_VERSION;
415
-        }
416
-    }
406
+	/**
407
+	 * UserAgent用户代理
408
+	 */
409
+	protected function getUserAgent()
410
+	{
411
+		if ($this->type == "TOP") {
412
+			return "ALIMEDIASDK_PHP_TAE/" . Conf::SDK_VERSION;
413
+		} else {
414
+			return "ALIMEDIASDK_PHP_CLOUD/" . Conf::SDK_VERSION;
415
+		}
416
+	}
417 417
 
418
-    /**
419
-     * 根据管理接口uri拼接成完整的URL
420
-     */
421
-    protected function getManageUrl($uri)
422
-    {
423
-        return Conf::MANAGE_HOST_MEDIA . $uri;
424
-    }
425
-    protected function getNamespaceKey()
426
-    {
427
-        if ($this->type == "TOP") {
428
-            return "namespace";
429
-        } else {
430
-            return "bucketName";
431
-        }
432
-    }
418
+	/**
419
+	 * 根据管理接口uri拼接成完整的URL
420
+	 */
421
+	protected function getManageUrl($uri)
422
+	{
423
+		return Conf::MANAGE_HOST_MEDIA . $uri;
424
+	}
425
+	protected function getNamespaceKey()
426
+	{
427
+		if ($this->type == "TOP") {
428
+			return "namespace";
429
+		} else {
430
+			return "bucketName";
431
+		}
432
+	}
433 433
 
434
-    /**
435
-     * 获取管理鉴权信息
436
-     */
437
-    protected function getAuthorization($uri, $date, $httpBody)
438
-    {
439
-        $stringBeforeSign = "{$uri}\n{$httpBody}\n{$date}"; //1.生成待加签的原始字符串
440
-        $signStr = hash_hmac('sha1', $stringBeforeSign, $this->sk); //2.使用SK对字符串计算HMAC-SHA1签名
441
-        $preenCode = $this->ak . ":" . $signStr; //3.将签名与AK进行拼接
442
-        $encodedStr = EncodeUtils::encodeWithURLSafeBase64($preenCode); //4.对拼接后的结果进行URL安全的Base64编码
443
-        $manageToken = "ACL_" . $this->type . " " . $encodedStr; //5.最后为编码结果加上得到管理凭证
444
-        return $manageToken;
445
-    }
434
+	/**
435
+	 * 获取管理鉴权信息
436
+	 */
437
+	protected function getAuthorization($uri, $date, $httpBody)
438
+	{
439
+		$stringBeforeSign = "{$uri}\n{$httpBody}\n{$date}"; //1.生成待加签的原始字符串
440
+		$signStr = hash_hmac('sha1', $stringBeforeSign, $this->sk); //2.使用SK对字符串计算HMAC-SHA1签名
441
+		$preenCode = $this->ak . ":" . $signStr; //3.将签名与AK进行拼接
442
+		$encodedStr = EncodeUtils::encodeWithURLSafeBase64($preenCode); //4.对拼接后的结果进行URL安全的Base64编码
443
+		$manageToken = "ACL_" . $this->type . " " . $encodedStr; //5.最后为编码结果加上得到管理凭证
444
+		return $manageToken;
445
+	}
446 446
 
447
-    /**
448
-     * 得到当前时间的毫秒数
449
-     */
450
-    protected function currentMilliSecond()
451
-    {
452
-        list($microSec, $stampSec) = explode(' ', microtime());
453
-        $tempMilli =  sprintf('%03s', intval($microSec * 1000));
454
-        $currentMilli = $stampSec . $tempMilli;
455
-        return $currentMilli;
456
-    }
447
+	/**
448
+	 * 得到当前时间的毫秒数
449
+	 */
450
+	protected function currentMilliSecond()
451
+	{
452
+		list($microSec, $stampSec) = explode(' ', microtime());
453
+		$tempMilli =  sprintf('%03s', intval($microSec * 1000));
454
+		$currentMilli = $stampSec . $tempMilli;
455
+		return $currentMilli;
456
+	}
457 457
 
458
-    /**
459
-     * 反馈错误信息
460
-     */
461
-    protected function errorResponse($code = "UnknownError", $message = "unkonown error", $requestId = null)
462
-    {
463
-        return array(
464
-            "isSuccess" => false,
465
-            "code" => $code,
466
-            "message" => $message,
467
-            "requestId" => $requestId
468
-        );
469
-    }
458
+	/**
459
+	 * 反馈错误信息
460
+	 */
461
+	protected function errorResponse($code = "UnknownError", $message = "unkonown error", $requestId = null)
462
+	{
463
+		return array(
464
+			"isSuccess" => false,
465
+			"code" => $code,
466
+			"message" => $message,
467
+			"requestId" => $requestId
468
+		);
469
+	}
470 470
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         $_headers = array('Expect:');
336 336
         $date = $this->currentMilliSecond(); //得到当前的时间戳,毫秒
337 337
         array_push($_headers, "Date: {$date}");
338
-        $authorization = $this->getAuthorization($uri, $date, $httpBody);  //Http的Body需要加入管理鉴权
338
+        $authorization = $this->getAuthorization($uri, $date, $httpBody); //Http的Body需要加入管理鉴权
339 339
         array_push($_headers, "Authorization: {$authorization}");
340 340
         array_push($_headers, "User-Agent: {$this->getUserAgent()}");
341 341
         if (!is_null($headers) && is_array($headers)) {
@@ -354,13 +354,13 @@  discard block
 block discarded – undo
354 354
                 array_push($_headers, "Content-Type: application/x-www-form-urlencoded");
355 355
             }
356 356
             array_push($_headers, "Content-Length: {$length}");
357
-            curl_setopt($ch, CURLOPT_HEADER, 1);                            //设置头部
358
-            curl_setopt($ch, CURLOPT_HTTPHEADER, $_headers);                //请求头
359
-            curl_setopt($ch, CURLOPT_TIMEOUT, Conf::HTTP_TIMEOUT);      //超时时长
360
-            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);               //连接超时时长
357
+            curl_setopt($ch, CURLOPT_HEADER, 1); //设置头部
358
+            curl_setopt($ch, CURLOPT_HTTPHEADER, $_headers); //请求头
359
+            curl_setopt($ch, CURLOPT_TIMEOUT, Conf::HTTP_TIMEOUT); //超时时长
360
+            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); //连接超时时长
361 361
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //成功,只返回结果,不自动输出任何内容。如果失败返回FALSE
362 362
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
363
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);           //自定义请求
363
+            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //自定义请求
364 364
             //设置请求方式(GET或POST等)
365 365
             if ($method == 'PUT' || $method == 'POST') {
366 366
                 curl_setopt($ch, CURLOPT_POST, 1);
@@ -375,10 +375,10 @@  discard block
 block discarded – undo
375 375
             } else {
376 376
                 //解析返回结果,并判断是否上传成功
377 377
                 $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
378
-                $success = ($http_code == 200) ? true : false;                  //判断是否上传成功
378
+                $success = ($http_code == 200) ? true : false; //判断是否上传成功
379 379
                 $resStr = explode("\r\n\r\n", $response);
380 380
                 $resBody = isset($resStr[1]) ? $resStr[1] : '';
381
-                $resArray = json_decode($resBody, true);                        //解析得到结果
381
+                $resArray = json_decode($resBody, true); //解析得到结果
382 382
                 $result = (empty($resArray)) ? array() : $resArray;
383 383
             }
384 384
         } catch (Exception $e) {
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
     protected function currentMilliSecond()
451 451
     {
452 452
         list($microSec, $stampSec) = explode(' ', microtime());
453
-        $tempMilli =  sprintf('%03s', intval($microSec * 1000));
453
+        $tempMilli = sprintf('%03s', intval($microSec * 1000));
454 454
         $currentMilli = $stampSec . $tempMilli;
455 455
         return $currentMilli;
456 456
     }
Please login to merge, or discard this patch.