⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
made the upload functionality api-only
daniel31x132be7f314bbff
diff --git a/apps/web/components/Preservation/PreservationNavbar.tsx b/apps/web/components/Preservation/PreservationNavbar.tsxindex 4445e736..1f1e5705 100644--- a/apps/web/components/Preservation/PreservationNavbar.tsx+++ b/apps/web/components/Preservation/PreservationNavbar.tsx@@ -24,8 +24,6 @@ import clsx from "clsx";import ToggleDarkMode from "../ToggleDarkMode";import TextStyleDropdown from "../TextStyleDropdown";import HighlightDrawer from "../HighlightDrawer";-import toast from "react-hot-toast";-import usePermissions from "@/hooks/usePermissions";type Props = {link: LinkIncludingShortenedCollectionAndTags;@@ -36,7 +34,6 @@ type Props = {const PreservationNavbar = ({ link, format, showNavbar, className }: Props) => {const { data: collections = [] } = useCollections();- const permissions = usePermissions(link.collection.id as number);const [collection, setCollection] =useState<CollectionIncludingMembersAndLinkCount>(@@ -59,31 +56,6 @@ const PreservationNavbar = ({ link, format, showNavbar, className }: Props) => {const { t } = useTranslation();const router = useRouter();- const handleFileUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {- const file = e.target.files?.[0];- if (!file) return;- const formBody = new FormData();- formBody.append("file", file);-- try {- const res = await fetch(`/api/v1/archives/${link?.id}?format=${format}`, {- method: "POST",- body: formBody,- });-- if (res.ok) {- router.reload();- } else {- const data = await res.json().catch(() => ({}));- console.error("Failed to replace file:", data);- toast.error(t("failed_to_replace_file"));- }- } catch (error) {- console.error("Failed to replace file:", error);- toast.error("failed_to_replace_file");- }- };-const handleDownload = () => {const path = `/api/v1/archives/${link?.id}?format=${format}`;fetch(path)@@ -107,10 +79,6 @@ const PreservationNavbar = ({ link, format, showNavbar, className }: Props) => {});};- const isPublicRoute = router.pathname.startsWith("/public") ? true : false;- const canUploadAsset =- (permissions === true || permissions?.canUpdate) && !isPublicRoute;-return (<><div@@ -129,33 +97,9 @@ const PreservationNavbar = ({ link, format, showNavbar, className }: Props) => {{format === ArchivedFormat.readability ? (<TextStyleDropdown />) : (- <>- <Button variant="ghost" size="icon" onClick={handleDownload}>- <i className="bi-cloud-arrow-down text-xl text-neutral" />- </Button>- {canUploadAsset && (- <Button asChild variant="ghost" size="icon">- <label className="cursor-pointer">- <i className="bi-cloud-arrow-up text-xl text-neutral" />- <input- type="file"- accept={- format === ArchivedFormat.monolith- ? "text/html,.html"- : format === ArchivedFormat.pdf- ? "application/pdf,.pdf"- : format === ArchivedFormat.png ||- format === ArchivedFormat.jpeg- ? "image/png,image/jpeg,.png,.jpg,.jpeg"- : undefined- }- className="hidden"- onChange={handleFileUpload}- />- </label>- </Button>- )}- </>+ <Button variant="ghost" size="icon" onClick={handleDownload}>+ <i className="bi-cloud-arrow-down text-xl text-neutral" />+ </Button>)}{format === ArchivedFormat.readability && (<Buttondiff --git a/apps/web/components/PreserverdFormatRow.tsx b/apps/web/components/PreserverdFormatRow.tsxindex b3f00295..fc296d9d 100644--- a/apps/web/components/PreserverdFormatRow.tsx+++ b/apps/web/components/PreserverdFormatRow.tsx@@ -61,6 +61,7 @@ export default function PreservedFormatRow({<i className="bi-cloud-arrow-down text-xl text-neutral" /></Button>) : undefined}+<Button asChild variant="ghost" size="icon"><Linkhref={`${diff --git a/apps/web/pages/api/v1/archives/[linkId].ts b/apps/web/pages/api/v1/archives/[linkId].tsindex 2a0819c9..35ceb6b1 100644--- a/apps/web/pages/api/v1/archives/[linkId].ts+++ b/apps/web/pages/api/v1/archives/[linkId].ts@@ -229,6 +229,7 @@ async function handlePost(req: NextApiRequest, res: NextApiResponse) {"image/jpeg","text/html",];+const fileBuffer = validateFile(files.file[0],NEXT_PUBLIC_MAX_FILE_BUFFER,@@ -279,6 +280,7 @@ async function handlePost(req: NextApiRequest, res: NextApiResponse) {isHTML && !isPreview? `archives/${collectionPermissions.id}/${linkId + suffix}`: undefined,+ clientSide: true,updatedAt: new Date().toISOString(),},});diff --git a/apps/web/pages/api/v1/links/[id]/archive/index.ts b/apps/web/pages/api/v1/links/[id]/archive/index.tsindex 2e145d72..755d1683 100644--- a/apps/web/pages/api/v1/links/[id]/archive/index.ts+++ b/apps/web/pages/api/v1/links/[id]/archive/index.ts@@ -60,6 +60,7 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {preview: null,lastPreserved: null,indexVersion: null,+ clientSide: false,},});diff --git a/apps/web/public/locales/en/common.json b/apps/web/public/locales/en/common.jsonindex 945f70d7..cc6df62e 100644--- a/apps/web/public/locales/en/common.json+++ b/apps/web/public/locales/en/common.json@@ -493,6 +493,5 @@"edit_layout": "Edit Layout","refresh_multiple_preserved_formats_confirmation_desc": "This will delete the current preserved formats and re-preserve {{count}} links.","refresh_preserved_formats_confirmation_desc": "This will delete the current preserved formats and re-preserve this link.",- "tag_already_added": "This tag is already added.",- "failed_to_replace_file": "Failed to replace this file."+ "tag_already_added": "This tag is already added."}diff --git a/packages/prisma/migrations/20250811155703_add_field_to_links/migration.sql b/packages/prisma/migrations/20250811155703_add_field_to_links/migration.sqlnew file mode 100644index 00000000..6dc54028--- /dev/null+++ b/packages/prisma/migrations/20250811155703_add_field_to_links/migration.sql@@ -0,0 +1,2 @@+-- AlterTable+ALTER TABLE "Link" ADD COLUMN "clientSide" BOOLEAN NOT NULL DEFAULT false;diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prismaindex fa3903f1..0ac01601 100644--- a/packages/prisma/schema.prisma+++ b/packages/prisma/schema.prisma@@ -182,6 +182,7 @@ model Link {pdf String?readable String?monolith String?+ clientSide Boolean @default(false)aiTagged Boolean @default(false)indexVersion Int?lastPreserved DateTime?