feat: implement download file

This commit is contained in:
Derrick Hammer 2024-03-27 06:05:48 -04:00
parent 810948242f
commit 44b9f625cc
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 7 additions and 2 deletions

View File

@ -15,6 +15,9 @@ import type { FileItem } from "~/data/file-provider";
import { usePinning } from "~/hooks/usePinning"; import { usePinning } from "~/hooks/usePinning";
import filesize from "~/components/lib/filesize"; import filesize from "~/components/lib/filesize";
import { Button } from "~/components/ui/button"; import { Button } from "~/components/ui/button";
import {useSdk} from "~/components/lib/sdk-context.js";
import {S5Client} from "@lumeweb/s5-js";
import {PROTOCOL_S5} from "@lumeweb/portal-sdk";
// This type is used to define the shape of our data. // This type is used to define the shape of our data.
@ -79,10 +82,12 @@ export const columns: ColumnDef<FileItem>[] = [
size: 20, size: 20,
cell: ({ row }) => { cell: ({ row }) => {
const { unpin } = usePinning(); const { unpin } = usePinning();
const sdk = useSdk();
const downloadFile = () => { const downloadFile = () => {
// TODO: @pcfreak30 download file
const cid = row.getValue("cid"); const cid = row.getValue("cid");
console.log(cid); const portalUrl = sdk.protocols!().get<S5Client>(PROTOCOL_S5).getSdk().portalUrl;
window.open(`${portalUrl}/s5/download/${cid}`,"_blank");
}; };
return ( return (
<div className="flex space-x-2 w-10 items-center justify-between"> <div className="flex space-x-2 w-10 items-center justify-between">