This commit is contained in:
2020-08-19 17:26:34 +02:00
parent 2e6e60e708
commit 312c8754bc

View File

@@ -9,6 +9,15 @@ interface Props {
file: File; file: File;
} }
const downloadLink = (name: string, url: string) => {
const downloadLink = document.createElement('a');
downloadLink.href = url;
downloadLink.download = name;
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
};
const Button = styled.button` const Button = styled.button`
background: none; background: none;
border: none; border: none;
@@ -37,9 +46,7 @@ const FileView: React.FC<Props> = ({
right={!!file.link && ( right={!!file.link && (
<> <>
<Cell> <Cell>
<a target="_blank" href={file.link}> <Button onClick={() => downloadLink(file.name, file.link)}><Download /></Button>
<Button><Download /></Button>
</a>
</Cell> </Cell>
<Cell> <Cell>
<Button onClick={remove}><Trash /></Button> <Button onClick={remove}><Trash /></Button>