#7936 improve InvoiceIn #1004
|
@ -2,25 +2,16 @@ import { useSession } from 'src/composables/useSession';
|
|||
import { getUrl } from './getUrl';
|
||||
import axios from 'axios';
|
||||
import { exportFile } from 'quasar';
|
||||
import useOpenURL from './useOpenURL';
|
||||
|
||||
const { getTokenMultimedia } = useSession();
|
||||
const token = getTokenMultimedia();
|
||||
|
||||
export async function downloadFile(
|
||||
id,
|
||||
model = 'dms',
|
||||
urlPath = '/downloadFile',
|
||||
url,
|
||||
newTab = true
|
||||
) {
|
||||
export async function downloadFile(id, model = 'dms', urlPath = '/downloadFile', url) {
|
||||
const appUrl = (await getUrl('', 'lilium')).replace('/#/', '');
|
||||
const targetUrl =
|
||||
url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`;
|
||||
|
||||
if (newTab) return useOpenURL(targetUrl);
|
||||
|
||||
const response = await axios.get(targetUrl, { responseType: 'blob' });
|
||||
const response = await axios.get(
|
||||
url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`,
|
||||
{ responseType: 'blob' }
|
||||
);
|
||||
|
||||
const contentDisposition = response.headers['content-disposition'];
|
||||
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(contentDisposition);
|
||||
|
|
Loading…
Reference in New Issue