chore: update returned attachement fullPath (#9516)
### Solution fullPath prop on attachement (when returned by backend) is updated to 'domain + path' (formerly 'path'). Consequently, getFileAbsoluteURI util in front is removed. closes #8763 --------- Co-authored-by: etiennejouan <jouan.etienne@gmail.com>
This commit is contained in:
@ -17,12 +17,10 @@ window.URL.revokeObjectURL = jest.fn();
|
||||
describe.skip('downloadFile', () => {
|
||||
it('should download a file', () => {
|
||||
// Call downloadFile
|
||||
downloadFile('path/to/file.pdf', 'file.pdf');
|
||||
downloadFile('url/to/file.pdf', 'file.pdf');
|
||||
|
||||
// Assert on fetch
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
process.env.REACT_APP_SERVER_BASE_URL + '/files/path/to/file.pdf',
|
||||
);
|
||||
expect(fetch).toHaveBeenCalledWith('url/to/file.pdf');
|
||||
|
||||
// Assert on element creation
|
||||
const link = document.querySelector(
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { saveAs } from 'file-saver';
|
||||
import { getFileAbsoluteURI } from '~/utils/file/getFileAbsoluteURI';
|
||||
|
||||
export const downloadFile = (fullPath: string, fileName: string) => {
|
||||
fetch(getFileAbsoluteURI(fullPath))
|
||||
fetch(fullPath)
|
||||
.then((resp) =>
|
||||
resp.status === 200
|
||||
? resp.blob()
|
||||
|
||||
Reference in New Issue
Block a user