#7936 improve InvoiceIn #1004

Merged
jorgep merged 55 commits from 7936-improveInvoiceIn into dev 2024-12-18 09:22:09 +00:00
1 changed files with 5 additions and 14 deletions
Showing only changes of commit 22daf36c6c - Show all commits

View File

@ -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);