Passed
Push — master ( 21a6a4...4428d0 )
by xiaohui
03:17
created
sdk/Utils/ResourceInfo.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -4,93 +4,93 @@
 block discarded – undo
4 4
 /**文件资源类*/
5 5
 class ResourceInfo
6 6
 {
7
-    /* 以下属性是资源ID所需的属性*/
8
-    protected $namespace;                              //空间名,必须
9
-    protected $dir;                                    //路径
10
-    protected $name;                                   //文件名信息
11
-    /* 以下属性是资源ID所需的属性*/
12
-    /**
13
-     * ResourceOption的构造函数
14
-     */
15
-    public function __construct($namespace, $dir = null, $name = null)
16
-    {
17
-        $this->namespace = $namespace;
18
-        $this->dir = $dir;
19
-        $this->name = $name;
20
-    }
21
-    /**检测资源ID的是否合法。$dirState表示是否检测dir,$nameState表示是否检测filename<p>
7
+	/* 以下属性是资源ID所需的属性*/
8
+	protected $namespace;                              //空间名,必须
9
+	protected $dir;                                    //路径
10
+	protected $name;                                   //文件名信息
11
+	/* 以下属性是资源ID所需的属性*/
12
+	/**
13
+	 * ResourceOption的构造函数
14
+	 */
15
+	public function __construct($namespace, $dir = null, $name = null)
16
+	{
17
+		$this->namespace = $namespace;
18
+		$this->dir = $dir;
19
+		$this->name = $name;
20
+	}
21
+	/**检测资源ID的是否合法。$dirState表示是否检测dir,$nameState表示是否检测filename<p>
22 22
      * 返回格式{$isValid, $message}*/
23
-    public function checkResourceInfo($dirState = false, $nameState = false)
24
-    {
25
-        if (empty($this->namespace)) {
26
-            return array(false, "namespace is empty.[{$this->toString()}]"); // 判断是否设置空间名
27
-        } else {
28
-            return $this->checkFileInfo($dirState, $nameState); // 判断dir和name的合法性
29
-        }
30
-    }
31
-    /**检测文件信息是否合法。$dirState表示是否检测dir,$nameState表示是否检测filename<p>
23
+	public function checkResourceInfo($dirState = false, $nameState = false)
24
+	{
25
+		if (empty($this->namespace)) {
26
+			return array(false, "namespace is empty.[{$this->toString()}]"); // 判断是否设置空间名
27
+		} else {
28
+			return $this->checkFileInfo($dirState, $nameState); // 判断dir和name的合法性
29
+		}
30
+	}
31
+	/**检测文件信息是否合法。$dirState表示是否检测dir,$nameState表示是否检测filename<p>
32 32
      * 返回格式{$isValid, $message}*/
33
-    public function checkFileInfo($dirState = false, $nameState = false)
34
-    {
35
-        if ($nameState && empty($this->name)) {
36
-            return array(false, "file's name is empty.[{$this->toString()}]"); // 1:若需要进行文件名name检测,则判断文件名是否为空
37
-        }
38
-        if ($dirState) {
39
-            if (empty($this->dir)) {
40
-                $this->dir = '/'; // 2:判断路径是否为空,若为空,则默认为根目录'/'
41
-            } elseif (strpos($this->dir, '/') !== 0) {
42
-                $this->dir = '/' . $this->dir; // 3:判断路径是否以'/'开头,若不是,则添加'/'
43
-            }
44
-        }
45
-        return array(true, null);
46
-    }
47
-    /**资源ID(resourceId)的生成*/
48
-    public function buildResourceId()
49
-    {
50
-        $jsonData = array();
51
-        if (!empty($this->namespace)) {
52
-            array_push($jsonData, urldecode($this->namespace));
53
-        }
54
-        if (!empty($this->dir)) {
55
-            array_push($jsonData, urldecode($this->dir));
56
-        }
57
-        if (!empty($this->name)) {
58
-            array_push($jsonData, urldecode($this->name));
59
-        }
60
-        return EncodeUtils::encodeWithURLSafeBase64(json_encode($jsonData, true));
61
-    }
62
-    /**对URL中文进行编码*/
63
-    protected function urlencodeCh($str)
64
-    {
65
-        return preg_replace_callback('/[^\0-\127]+/', function ($match) {
66
-            return urlencode($match[0]);
67
-        }, $str);
68
-    }
69
-    public function toString()
70
-    {
71
-        return "namespace={$this->namespace}, dir={$this->dir}, name={$this->name}";
72
-    }
73
-    public function toArray()
74
-    {
75
-        return array("namespace" => $this->namespace, "dir" => $this->dir, "name" => $this->name);
76
-    }
77
-    /*###################下面是属性的get和set方法###############*/
78
-    /**设置路径*/
79
-    public function setNamespace($namespace)
80
-    {
81
-        $this->namespace = $namespace;
82
-        return $this;
83
-    }
84
-    /**设置路径*/
85
-    public function setDir($dir)
86
-    {
87
-        $this->dir = $dir;
88
-        return $this;
89
-    }
90
-    /**设置文件名*/
91
-    public function setName($filename)
92
-    {
93
-        $this->name = $filename;
94
-        return $this;
95
-    }
33
+	public function checkFileInfo($dirState = false, $nameState = false)
34
+	{
35
+		if ($nameState && empty($this->name)) {
36
+			return array(false, "file's name is empty.[{$this->toString()}]"); // 1:若需要进行文件名name检测,则判断文件名是否为空
37
+		}
38
+		if ($dirState) {
39
+			if (empty($this->dir)) {
40
+				$this->dir = '/'; // 2:判断路径是否为空,若为空,则默认为根目录'/'
41
+			} elseif (strpos($this->dir, '/') !== 0) {
42
+				$this->dir = '/' . $this->dir; // 3:判断路径是否以'/'开头,若不是,则添加'/'
43
+			}
44
+		}
45
+		return array(true, null);
46
+	}
47
+	/**资源ID(resourceId)的生成*/
48
+	public function buildResourceId()
49
+	{
50
+		$jsonData = array();
51
+		if (!empty($this->namespace)) {
52
+			array_push($jsonData, urldecode($this->namespace));
53
+		}
54
+		if (!empty($this->dir)) {
55
+			array_push($jsonData, urldecode($this->dir));
56
+		}
57
+		if (!empty($this->name)) {
58
+			array_push($jsonData, urldecode($this->name));
59
+		}
60
+		return EncodeUtils::encodeWithURLSafeBase64(json_encode($jsonData, true));
61
+	}
62
+	/**对URL中文进行编码*/
63
+	protected function urlencodeCh($str)
64
+	{
65
+		return preg_replace_callback('/[^\0-\127]+/', function ($match) {
66
+			return urlencode($match[0]);
67
+		}, $str);
68
+	}
69
+	public function toString()
70
+	{
71
+		return "namespace={$this->namespace}, dir={$this->dir}, name={$this->name}";
72
+	}
73
+	public function toArray()
74
+	{
75
+		return array("namespace" => $this->namespace, "dir" => $this->dir, "name" => $this->name);
76
+	}
77
+	/*###################下面是属性的get和set方法###############*/
78
+	/**设置路径*/
79
+	public function setNamespace($namespace)
80
+	{
81
+		$this->namespace = $namespace;
82
+		return $this;
83
+	}
84
+	/**设置路径*/
85
+	public function setDir($dir)
86
+	{
87
+		$this->dir = $dir;
88
+		return $this;
89
+	}
90
+	/**设置文件名*/
91
+	public function setName($filename)
92
+	{
93
+		$this->name = $filename;
94
+		return $this;
95
+	}
96 96
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@  discard block
 block discarded – undo
5 5
 class ResourceInfo
6 6
 {
7 7
     /* 以下属性是资源ID所需的属性*/
8
-    protected $namespace;                              //空间名,必须
9
-    protected $dir;                                    //路径
10
-    protected $name;                                   //文件名信息
8
+    protected $namespace; //空间名,必须
9
+    protected $dir; //路径
10
+    protected $name; //文件名信息
11 11
     /* 以下属性是资源ID所需的属性*/
12 12
     /**
13 13
      * ResourceOption的构造函数
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     /**对URL中文进行编码*/
63 63
     protected function urlencodeCh($str)
64 64
     {
65
-        return preg_replace_callback('/[^\0-\127]+/', function ($match) {
65
+        return preg_replace_callback('/[^\0-\127]+/', function($match) {
66 66
             return urlencode($match[0]);
67 67
         }, $str);
68 68
     }
Please login to merge, or discard this patch.
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.