Proxy file downloads through the panel rather than having to get creative with download tokens

This commit is contained in:
Dane Everitt 2019-10-26 14:36:37 -07:00
parent 78ccdf93b6
commit 0b9c6bd21d
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 78 additions and 43 deletions

View file

@ -13,7 +13,7 @@ import { join } from 'path';
import deleteFile from '@/api/server/files/deleteFile';
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
import copyFile from '@/api/server/files/copyFile';
import { httpErrorToHuman } from '@/api/http';
import http, { httpErrorToHuman } from '@/api/http';
type ModalType = 'rename' | 'move';
@ -69,6 +69,10 @@ export default ({ uuid }: { uuid: string }) => {
});
};
const doDownload = () => {
window.location = `/api/client/servers/${server.uuid}/files/download?file=${join(directory, file.name)}` as unknown as Location;
};
useEffect(() => {
menuVisible
? document.addEventListener('click', windowListener)
@ -138,7 +142,10 @@ export default ({ uuid }: { uuid: string }) => {
<FontAwesomeIcon icon={faCopy} className={'text-xs'}/>
<span className={'ml-2'}>Copy</span>
</div>
<div className={'hover:text-neutral-700 p-2 flex items-center hover:bg-neutral-100 rounded'}>
<div
className={'hover:text-neutral-700 p-2 flex items-center hover:bg-neutral-100 rounded'}
onClick={() => doDownload()}
>
<FontAwesomeIcon icon={faFileDownload} className={'text-xs'}/>
<span className={'ml-2'}>Download</span>
</div>