mirror of
https://github.com/morten-olsen/parcel.git
synced 2026-02-08 01:36:24 +01:00
download
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user