mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix handline of large file uploads and properly show any errors that may occur. Fixes #2153
This commit is contained in:
committed by
Dave Page
parent
dcc74af87b
commit
8bbcf0ab36
@@ -1490,14 +1490,15 @@ def load_file():
|
||||
errormsg=gettext("File type not supported")
|
||||
)
|
||||
|
||||
with codecs.open(file_path, 'r', encoding=enc) as fileObj:
|
||||
data = fileObj.read()
|
||||
def gen():
|
||||
with codecs.open(file_path, 'r', encoding=enc) as fileObj:
|
||||
while True:
|
||||
data = fileObj.read(4194304) # 4MB chunk (4 * 1024 * 1024 Bytes)
|
||||
if not data:
|
||||
break
|
||||
yield data
|
||||
|
||||
return make_json_response(
|
||||
data={
|
||||
'status': True, 'result': data,
|
||||
}
|
||||
)
|
||||
return Response(gen(), mimetype='text/plain')
|
||||
|
||||
|
||||
@blueprint.route('/save_file/', methods=["PUT", "POST"], endpoint='save_file')
|
||||
|
||||
@@ -2542,11 +2542,9 @@ define([
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(data),
|
||||
success: function(res) {
|
||||
if (res.data.status) {
|
||||
self.gridView.query_tool_obj.setValue(res.data.result);
|
||||
self.gridView.current_file = e;
|
||||
self.setTitle(self.gridView.current_file.split('\\').pop().split('/').pop());
|
||||
}
|
||||
self.gridView.query_tool_obj.setValue(res);
|
||||
self.gridView.current_file = e;
|
||||
self.setTitle(self.gridView.current_file.split('\\').pop().split('/').pop());
|
||||
self.trigger('pgadmin-sqleditor:loading-icon:hide');
|
||||
// hide cursor
|
||||
$busy_icon_div.removeClass('show_progress');
|
||||
|
||||
Reference in New Issue
Block a user