diff --git a/application/config.php b/application/config.php index fd8a9488..95658562 100644 --- a/application/config.php +++ b/application/config.php @@ -240,6 +240,12 @@ return [ 'var_page' => 'page', 'list_rows' => 15, ], + + //分片上传大小(只对本地策略有效) + 'upload'=>[ + 'chunk_size' => 10*1024*1024, + ], + // +---------------------------------------------------------------------- // | 验证码设置 // +---------------------------------------------------------------------- diff --git a/application/index/controller/Home.php b/application/index/controller/Home.php index f72eb3d4..96c76dd6 100644 --- a/application/index/controller/Home.php +++ b/application/index/controller/Home.php @@ -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"), ]); } diff --git a/application/index/model/UploadHandler.php b/application/index/model/UploadHandler.php index e209f80c..b6e2d71d 100644 --- a/application/index/model/UploadHandler.php +++ b/application/index/model/UploadHandler.php @@ -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"); diff --git a/application/index/view/home/home.html b/application/index/view/home/home.html index ef0ce1c7..3252f3f2 100644 --- a/application/index/view/home/home.html +++ b/application/index/view/home/home.html @@ -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`. --> - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/static/js/uploader/qiniu.js b/static/js/uploader/qiniu.js index b949dbcb..4f0b457e 100644 --- a/static/js/uploader/qiniu.js +++ b/static/js/uploader/qiniu.js @@ -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 }