Skip to content

Commit

Permalink
增加默认文件大小
Browse files Browse the repository at this point in the history
  • Loading branch information
thanatos915 committed Jul 24, 2018
1 parent 49f4824 commit 0f495cf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Oss.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,19 @@ public function getObjectSize($object)
}

/**
* 获取OSS JS 的签名
* @param int $expire
* @return string
* @author thanatos <thanatos915@163.com>
*/
public function getSignature($dir = 'uploads', $expire = 2592000)
/**
* 获取OSS JS 的签名
* @param string $dir
* @param int $maxSize 最大文件大小 默认 20M
* @param int $expire 过期时间
* @return array
* @author thanatos <thanatos915@163.com>
*/
public function getSignature($dir = 'uploads', $maxSize = 2097150, $expire = 2592000)
{
$now = time();
$end = $now + $expire;
Expand All @@ -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上传到别人的目录
Expand Down

0 comments on commit 0f495cf

Please sign in to comment.