dpgaspar 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_r373043185
 
 

 ##########
 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:
   Did a stream upload with configurable chunks. Yet this may not address the 
OOM issue if it's related with the pandas dataframe csv loading

----------------------------------------------------------------
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]

Reply via email to