eschutho commented on a change in pull request #19051:
URL: https://github.com/apache/superset/pull/19051#discussion_r830297691



##########
File path: superset/databases/api.py
##########
@@ -1039,3 +1061,44 @@ def validate_parameters(self) -> FlaskResponse:
         command = ValidateDatabaseParametersCommand(g.user, payload)
         command.run()
         return self.response(200, message="OK")
+
+    @expose("/upload_enabled/", methods=["GET"])
+    @protect()
+    @statsd_metrics
+    @event_logger.log_this_with_context(
+        action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
+        f".upload_enabled",
+        log_to_statsd=False,
+    )
+    def upload_enabled(self) -> Response:
+        """Returns a boolean saying whether uploads are enabled for the user
+        ---
+        get:
+          description:
+            Get the status of if any databases have allow file upload enabled
+            and also have a schema in a database that can have files uploaded 
to it.
+          responses:
+            200:
+              description: Database names
+              content:
+                application/json:
+                  schema:
+                    type: boolean
+            400:
+              $ref: '#/components/responses/400'
+            500:
+              $ref: '#/components/responses/500'
+        """
+        try:
+            dbs_with_uploads = (
+                
db.session.query(Database).filter_by(allow_file_upload=True).all()
+            )
+
+            allow_uploads = any(
+                len(db.get_schema_access_for_file_upload()) >= 1

Review comment:
       @AAfghahi this may be complicated but I think we will need to check if 
the schemas in the config are part of those dbs. 




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

To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to