fix: refs #7936 rollback
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-12-17 11:58:57 +01:00
parent ad9063704c
commit 22daf36c6c
1 changed files with 5 additions and 14 deletions

View File

@ -2,25 +2,16 @@ import { useSession } from 'src/composables/useSession';
import { getUrl } from './getUrl'; import { getUrl } from './getUrl';
import axios from 'axios'; import axios from 'axios';
import { exportFile } from 'quasar'; import { exportFile } from 'quasar';
import useOpenURL from './useOpenURL';
const { getTokenMultimedia } = useSession(); const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia(); const token = getTokenMultimedia();
export async function downloadFile( export async function downloadFile(id, model = 'dms', urlPath = '/downloadFile', url) {
id,
model = 'dms',
urlPath = '/downloadFile',
url,
newTab = true
) {
const appUrl = (await getUrl('', 'lilium')).replace('/#/', ''); const appUrl = (await getUrl('', 'lilium')).replace('/#/', '');
const targetUrl = const response = await axios.get(
url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`; url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`,
{ responseType: 'blob' }
if (newTab) return useOpenURL(targetUrl); );
const response = await axios.get(targetUrl, { 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);