Vitor-Avila commented on code in PR #34988:
URL: https://github.com/apache/superset/pull/34988#discussion_r2317645243


##########
superset-frontend/src/dashboard/hooks/useDownloadScreenshot.ts:
##########
@@ -98,12 +98,25 @@ export const useDownloadScreenshot = (
           headers: { Accept: 'application/pdf, image/png' },
           parseMethod: 'raw',
         })
-          .then((response: Response) => response.blob())
-          .then(blob => {
+          .then((response: Response) => {
+            const disposition = response.headers.get('Content-Disposition');
+            let filename = `screenshot.${format}`; // default filename
+
+            if (disposition && disposition.includes('filename=')) {
+              const filenameRegex = /filename="([^"]+)"/;
+              const matches = filenameRegex.exec(disposition);
+              if (matches && matches[1]) {
+                filename = matches[1];
+              }
+            }
+
+            return response.blob().then(blob => ({ blob, filename }));
+          })

Review Comment:
   Great suggestion! Let me work on this



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to