Feat: 自定义分片大小
This commit is contained in:
parent
b2d5547199
commit
74d0afb441
5 changed files with 30 additions and 18 deletions
|
@ -240,6 +240,12 @@ return [
|
|||
'var_page' => 'page',
|
||||
'list_rows' => 15,
|
||||
],
|
||||
|
||||
//分片上传大小(只对本地策略有效)
|
||||
'upload'=>[
|
||||
'chunk_size' => 10*1024*1024,
|
||||
],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 验证码设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
|
|
@ -35,6 +35,7 @@ class Home extends Controller{
|
|||
'extLimit' => $extLimit,
|
||||
'policyData' => $policyData,
|
||||
'groupData' => $groupData,
|
||||
'chunkSize' => config('upload.chunk_size'),
|
||||
'path' => empty(input("get.path"))?"/":input("get.path"),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class UploadHandler extends Model{
|
|||
$this->setError("空间容量不足",false);
|
||||
}
|
||||
FileManage::storageCheckOut($this->userId,$chunkSize);
|
||||
if($chunkSize >=4195304){
|
||||
if($chunkSize >config('upload.chunk_size')){
|
||||
$this->setError("分片错误",false);
|
||||
}
|
||||
$chunkObj=fopen (ROOT_PATH . 'public/uploads/chunks/'.$this->chunkData["obj_name"].".chunk","w+");
|
||||
|
@ -198,8 +198,8 @@ class UploadHandler extends Model{
|
|||
if(!$fileObj || !$chunkObj){
|
||||
$this->setError("文件创建失败",false);
|
||||
}
|
||||
$content = fread($chunkObj, 4195304);
|
||||
fwrite($fileObj, $content, 4195304);
|
||||
$content = fread($chunkObj, config('upload.chunk_size'));
|
||||
fwrite($fileObj, $content, config('upload.chunk_size'));
|
||||
unset($content);
|
||||
fclose($chunkObj);
|
||||
unlink(ROOT_PATH . 'public/uploads/chunks/'.$value["obj_name"].".chunk");
|
||||
|
|
|
@ -36,6 +36,13 @@
|
|||
allowRemoteDownload: "{:explode(",",$groupData.aria2)[0]}",
|
||||
allowTorrentDownload: "{:explode(",",$groupData.aria2)[1]}",
|
||||
};
|
||||
if(uploadConfig.saveType == "oss" || uploadConfig.saveType == "upyun" || uploadConfig.saveType == "s3"){
|
||||
ChunkSize = "0";
|
||||
}else if(uploadConfig.saveType == "qiniu" ){
|
||||
ChunkSize = 4*1024*1024;
|
||||
}else{
|
||||
ChunkSize = {$chunkSize};
|
||||
}
|
||||
apiURL = {
|
||||
imgThumb: "/File/Thumb",
|
||||
preview: "/File/Preview",
|
||||
|
@ -78,17 +85,17 @@
|
|||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
<script src="http://192.168.123.19:3000/static/js/runtime~index.bundle.js"></script>
|
||||
<script src="http://192.168.123.19:3000/static/js/0.chunk.js"></script>
|
||||
<script src="http://192.168.123.19:3000/static/js/2.chunk.js"></script>
|
||||
<script src="http://192.168.123.19:3000/static/js/3.chunk.js"></script>
|
||||
<script src="http://192.168.123.19:3000/static/js/4.chunk.js"></script>
|
||||
<script src="http://192.168.123.19:3000/static/js/6.chunk.js"></script>
|
||||
<script src="http://192.168.123.19:3000/static/js/7.chunk.js"></script>
|
||||
<script src="http://192.168.123.19:3000/static/js/9.chunk.js"></script>
|
||||
<script src="http://192.168.123.19:3000/static/js/1.chunk.js"></script>
|
||||
<script src="http://192.168.123.19:3000/static/js/8.chunk.js"></script>
|
||||
<script src="http://192.168.123.19:3000/static/js/12.chunk.js"></script>
|
||||
<script src="http://192.168.123.19:3000/static/js/index.chunk.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/runtime~index.bundle.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/0.chunk.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/2.chunk.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/3.chunk.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/4.chunk.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/6.chunk.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/7.chunk.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/9.chunk.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/1.chunk.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/8.chunk.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/12.chunk.js"></script>
|
||||
<script src="http://127.0.0.1:3000/static/js/index.chunk.js"></script>
|
||||
|
||||
</html>
|
|
@ -595,9 +595,7 @@ function QiniuJsSDK() {
|
|||
MAX_CHUNK_SIZE = 4 << BLOCK_BITS; //4M
|
||||
|
||||
chunk_size = plupload.parseSize(op.chunk_size);
|
||||
if (chunk_size > MAX_CHUNK_SIZE) {
|
||||
op.chunk_size = MAX_CHUNK_SIZE;
|
||||
}
|
||||
|
||||
// qiniu service max_chunk_size is 4m
|
||||
// reset chunk_size to max_chunk_size(4m) when chunk_size > 4m
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue