Fix handline of large file uploads and properly show any errors that may occur. Fixes #2153

This commit is contained in:
Harshal Dhumal
2017-07-17 10:51:26 +01:00
committed by Dave Page
parent dcc74af87b
commit 8bbcf0ab36
4 changed files with 18 additions and 15 deletions

View File

@@ -886,10 +886,14 @@ class Filemanager(object):
newName = u"{0}{1}".format(orig_path, file_name)
with open(newName, 'wb') as f:
f.write(file_obj.read())
while True:
data = file_obj.read(4194304) # 4MB chunk (4 * 1024 * 1024 Bytes)
if not data:
break
f.write(data)
except Exception as e:
code = 0
err_msg = u"Error: {0}".format(e.strerror)
err_msg = u"Error: {0}".format(e.strerror if hasattr(e, 'strerror') else u'Unknown')
try:
Filemanager.check_access_permission(dir, path)

View File

@@ -1624,7 +1624,7 @@ if (has_capability(data, 'upload')) {
complete: function(file) {
if (file.status == "error") {
var alertifyWrapper = new AlertifyWrapper();
alertifyWrapper.error(lg.ERROR_UPLOADING_FILE);
alertifyWrapper.error(lg.upload_error);
}
$('.upload_file .dz_cross_btn').removeAttr('disabled');
getFolderInfo(path);