mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-06 07:46:32 +00:00
fix missing attached filenames (#3172)
Signed-off-by: Ruslan Bayandinov <wazsone@ya.ru>
This commit is contained in:
parent
0473d9eaf9
commit
a57f3b8c2f
@ -61,7 +61,7 @@
|
|||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
|
|
||||||
<svelte:fragment slot="utils">
|
<svelte:fragment slot="utils">
|
||||||
<a class="no-line" href={getFileUrl(file)} download={name} bind:this={download}>
|
<a class="no-line" href={getFileUrl(file, 'full', name)} download={name} bind:this={download}>
|
||||||
<Button
|
<Button
|
||||||
icon={Download}
|
icon={Download}
|
||||||
kind={'transparent'}
|
kind={'transparent'}
|
||||||
@ -75,14 +75,14 @@
|
|||||||
|
|
||||||
{#if contentType && contentType.startsWith('image/')}
|
{#if contentType && contentType.startsWith('image/')}
|
||||||
<div class="pdfviewer-content img" style:margin={$deviceInfo.minWidth ? '.5rem' : '1.5rem'}>
|
<div class="pdfviewer-content img" style:margin={$deviceInfo.minWidth ? '.5rem' : '1.5rem'}>
|
||||||
<img class="img-fit" src={getFileUrl(file)} alt="" />
|
<img class="img-fit" src={getFileUrl(file, 'full', name)} alt="" />
|
||||||
</div>
|
</div>
|
||||||
<div class="space" />
|
<div class="space" />
|
||||||
{:else}
|
{:else}
|
||||||
<iframe
|
<iframe
|
||||||
class="pdfviewer-content"
|
class="pdfviewer-content"
|
||||||
style:margin={$deviceInfo.minWidth ? '.5rem' : '1.5rem'}
|
style:margin={$deviceInfo.minWidth ? '.5rem' : '1.5rem'}
|
||||||
src={getFileUrl(file) + '#view=FitH&navpanes=0'}
|
src={getFileUrl(file, 'full', name) + '#view=FitH&navpanes=0'}
|
||||||
title=""
|
title=""
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -260,14 +260,16 @@ export function createQuery (dontDestroy?: boolean): LiveQuery {
|
|||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export function getFileUrl (file: string, size: IconSize = 'full'): string {
|
export function getFileUrl (file: string, size: IconSize = 'full', filename?: string): string {
|
||||||
if (file.includes('://')) {
|
if (file.includes('://')) {
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
const uploadUrl = getMetadata(plugin.metadata.UploadURL)
|
const uploadUrl = getMetadata(plugin.metadata.UploadURL)
|
||||||
const token = getMetadata(plugin.metadata.Token)
|
const token = getMetadata(plugin.metadata.Token)
|
||||||
const url = `${uploadUrl as string}?file=${file}&token=${token as string}&size=${size as string}`
|
if (filename !== undefined) {
|
||||||
return url
|
return `${uploadUrl as string}/${filename}?file=${file}&token=${token as string}&size=${size as string}`
|
||||||
|
}
|
||||||
|
return `${uploadUrl as string}?file=${file}&token=${token as string}&size=${size as string}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,8 +216,7 @@ export function start (
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
const filesHandler = async (req: any, res: Response): Promise<void> => {
|
||||||
app.get('/files', async (req, res: Response) => {
|
|
||||||
try {
|
try {
|
||||||
const token = req.query.token as string
|
const token = req.query.token as string
|
||||||
const payload = decodeToken(token)
|
const payload = decodeToken(token)
|
||||||
@ -236,7 +235,13 @@ export function start (
|
|||||||
console.log(error)
|
console.log(error)
|
||||||
res.status(500).send()
|
res.status(500).send()
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
|
app.get('/files/', filesHandler)
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
|
app.get('/files/*', filesHandler)
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
app.post('/files', async (req, res) => {
|
app.post('/files', async (req, res) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user