craig-rueda commented on a change in pull request #9047: [csv upload] Use
python's named temp file
URL:
https://github.com/apache/incubator-superset/pull/9047#discussion_r372518838
##########
File path: superset/views/database/views.py
##########
@@ -91,11 +91,14 @@ def form_post(self, form):
return redirect("/csvtodatabaseview/form")
csv_file = form.csv_file.data
- form.csv_file.data.filename =
secure_filename(form.csv_file.data.filename)
+
csv_filename = form.csv_file.data.filename
- path = os.path.join(config["UPLOAD_FOLDER"], csv_filename)
+ extension = os.path.splitext(csv_filename)[1].lower()
+ path = tempfile.NamedTemporaryFile(
+ dir=app.config["UPLOAD_FOLDER"], suffix=extension
+ ).name
+ form.csv_file.data.filename = path
try:
- utils.ensure_path_exists(config["UPLOAD_FOLDER"])
csv_file.save(path)
Review comment:
Where does the file live before this call to save()? In mem?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]