Refactor File Download Logic and Streamline Test Suite (#9281)
Closes #9277 ## Summary of Changes - Updated the file-download functionality to use the `saveAs` method from the `file-saver` library, ensuring a more reliable and consistent implementation. - Removed redundant tests to streamline the test suite and reduce maintenance overhead. ## Testing Performed - [x] Verified that exporting the view to a CSV file works as expected.
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { saveAs } from 'file-saver';
|
||||
import { getFileAbsoluteURI } from '~/utils/file/getFileAbsoluteURI';
|
||||
|
||||
export const downloadFile = (fullPath: string, fileName: string) => {
|
||||
@ -8,13 +9,6 @@ export const downloadFile = (fullPath: string, fileName: string) => {
|
||||
: Promise.reject('Failed downloading file'),
|
||||
)
|
||||
.then((blob) => {
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none';
|
||||
a.href = url;
|
||||
a.download = fileName;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
saveAs(blob, fileName);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user