mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 03:22:19 +03: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 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
|
||||
icon={Download}
|
||||
kind={'transparent'}
|
||||
@ -75,14 +75,14 @@
|
||||
|
||||
{#if contentType && contentType.startsWith('image/')}
|
||||
<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 class="space" />
|
||||
{:else}
|
||||
<iframe
|
||||
class="pdfviewer-content"
|
||||
style:margin={$deviceInfo.minWidth ? '.5rem' : '1.5rem'}
|
||||
src={getFileUrl(file) + '#view=FitH&navpanes=0'}
|
||||
src={getFileUrl(file, 'full', name) + '#view=FitH&navpanes=0'}
|
||||
title=""
|
||||
/>
|
||||
{/if}
|
||||
|
@ -260,14 +260,16 @@ export function createQuery (dontDestroy?: boolean): LiveQuery {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function getFileUrl (file: string, size: IconSize = 'full'): string {
|
||||
export function getFileUrl (file: string, size: IconSize = 'full', filename?: string): string {
|
||||
if (file.includes('://')) {
|
||||
return file
|
||||
}
|
||||
const uploadUrl = getMetadata(plugin.metadata.UploadURL)
|
||||
const token = getMetadata(plugin.metadata.Token)
|
||||
const url = `${uploadUrl as string}?file=${file}&token=${token as string}&size=${size as string}`
|
||||
return url
|
||||
if (filename !== undefined) {
|
||||
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
|
||||
app.get('/files', async (req, res: Response) => {
|
||||
const filesHandler = async (req: any, res: Response): Promise<void> => {
|
||||
try {
|
||||
const token = req.query.token as string
|
||||
const payload = decodeToken(token)
|
||||
@ -236,7 +235,13 @@ export function start (
|
||||
console.log(error)
|
||||
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
|
||||
app.post('/files', async (req, res) => {
|
||||
|
Loading…
Reference in New Issue
Block a user