From 0f495cfe60546edae5edc4155c6adbd25690ce10 Mon Sep 17 00:00:00 2001 From: thanatos Date: Tue, 24 Jul 2018 13:46:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Oss.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Oss.php b/src/Oss.php index 48143e5..900997d 100644 --- a/src/Oss.php +++ b/src/Oss.php @@ -258,12 +258,19 @@ public function getObjectSize($object) } /** - * 获取OSS JS 的签名 * @param int $expire * @return string * @author thanatos */ - public function getSignature($dir = 'uploads', $expire = 2592000) + /** + * 获取OSS JS 的签名 + * @param string $dir + * @param int $maxSize 最大文件大小 默认 20M + * @param int $expire 过期时间 + * @return array + * @author thanatos + */ + public function getSignature($dir = 'uploads', $maxSize = 2097150, $expire = 2592000) { $now = time(); $end = $now + $expire; @@ -280,7 +287,7 @@ public function getSignature($dir = 'uploads', $expire = 2592000) } //最大文件大小.用户可以自己设置 - $condition = array(0 => 'content-length-range', 1 => 0, 2 => $expire); + $condition = array(0 => 'content-length-range', 1 => 0, 2 => $maxSize); $conditions[] = $condition; //表示用户上传的数据,必须是以$dir开始, 不然上传会失败,这一步不是必须项,只是为了安全起见,防止用户通过policy上传到别人的目录