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.
15 lines
406 B
TypeScript
15 lines
406 B
TypeScript
import { saveAs } from 'file-saver';
|
|
import { getFileAbsoluteURI } from '~/utils/file/getFileAbsoluteURI';
|
|
|
|
export const downloadFile = (fullPath: string, fileName: string) => {
|
|
fetch(getFileAbsoluteURI(fullPath))
|
|
.then((resp) =>
|
|
resp.status === 200
|
|
? resp.blob()
|
|
: Promise.reject('Failed downloading file'),
|
|
)
|
|
.then((blob) => {
|
|
saveAs(blob, fileName);
|
|
});
|
|
};
|