forked from verdnatura/salix-front
fix: refs #7229 remove catch
This commit is contained in:
parent
85aeda337f
commit
9665a3407f
|
@ -7,22 +7,18 @@ const { getTokenMultimedia } = useSession();
|
||||||
const token = getTokenMultimedia();
|
const token = getTokenMultimedia();
|
||||||
|
|
||||||
export async function downloadFile(id, model = 'dms', urlPath = '/downloadFile', url) {
|
export async function downloadFile(id, model = 'dms', urlPath = '/downloadFile', url) {
|
||||||
try {
|
const appUrl = (await getUrl('', 'lilium')).replace('/#/', '');
|
||||||
const appUrl = (await getUrl('', 'lilium')).replace('/#/', '');
|
const response = await axios.get(
|
||||||
const response = await axios.get(
|
url ?? `${appUrl}/${model}/${id}${urlPath}?access_token=${token}`,
|
||||||
url ?? `${appUrl}/${model}/${id}${urlPath}?access_token=${token}`,
|
{ responseType: 'blob' }
|
||||||
{ responseType: 'blob' }
|
);
|
||||||
);
|
|
||||||
|
|
||||||
const contentDisposition = response.headers['content-disposition'];
|
const contentDisposition = response.headers['content-disposition'];
|
||||||
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(contentDisposition);
|
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(contentDisposition);
|
||||||
const filename =
|
const filename =
|
||||||
matches != null && matches[1]
|
matches != null && matches[1]
|
||||||
? matches[1].replace(/['"]/g, '')
|
? matches[1].replace(/['"]/g, '')
|
||||||
: 'downloaded-file';
|
: 'downloaded-file';
|
||||||
|
|
||||||
exportFile(filename, response.data);
|
exportFile(filename, response.data);
|
||||||
} catch (error) {
|
|
||||||
console.error('Error downloading the file', error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue