Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: add more file types
Marc Seitzdb2837386112
diff --git a/components/document-upload.tsx b/components/document-upload.tsxindex 2c625c45..cf77f234 100644--- a/components/document-upload.tsx+++ b/components/document-upload.tsx@@ -11,10 +11,16 @@ import { fileIcon } from "@/lib/utils/get-file-icon";import { getPagesCount } from "@/lib/utils/get-page-number-count";const fileSizeLimits: { [key: string]: number } = {- "application/vnd.ms-excel": 100, // 30 MB+ "application/vnd.ms-excel": 30, // 30 MB"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": 30, // 30 MB- "text/csv": 30, // 30 MB"application/vnd.oasis.opendocument.spreadsheet": 30, // 30 MB+ "application/vnd.ms-powerpoint": 30, // 30 MB+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": 30, // 30 MB+ "application/vnd.oasis.opendocument.presentation": 30, // 30 MB+ "application/msword": 30, // 30 MB+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": 30, // 30 MB+ "application/vnd.oasis.opendocument.text": 30, // 30 MB+ "text/csv": 30, // 30 MB};export default function DocumentUpload({@@ -38,6 +44,14 @@ export default function DocumentUpload({"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [], // ".xlsx""text/csv": [], // ".csv""application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"+ "application/vnd.ms-powerpoint": [], // ".ppt"+ "application/vnd.openxmlformats-officedocument.presentationml.presentation":+ [], // ".pptx"+ "application/vnd.oasis.opendocument.presentation": [], // ".odp"+ "application/msword": [], // ".doc"+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document":+ [], // ".docx"+ "application/vnd.oasis.opendocument.text": [], // ".odt"},multiple: false,maxSize: maxSize * 1024 * 1024, // 30 MBdiff --git a/components/upload-zone.tsx b/components/upload-zone.tsxindex 1a3de19a..52755f1f 100644--- a/components/upload-zone.tsx+++ b/components/upload-zone.tsx@@ -242,6 +242,14 @@ export default function UploadZone({"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [], // ".xlsx""text/csv": [], // ".csv""application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document":+ [], // ".docx"+ "application/vnd.openxmlformats-officedocument.presentationml.presentation":+ [], // ".pptx"+ "application/vnd.ms-powerpoint": [], // ".ppt"+ "application/msword": [], // ".doc"+ "application/vnd.oasis.opendocument.text": [], // ".odt"+ "application/vnd.oasis.opendocument.presentation": [], // ".odp"},multiple: true,maxSize: maxSize * 1024 * 1024, // 30 MBdiff --git a/components/view/dataroom/dataroom-view.tsx b/components/view/dataroom/dataroom-view.tsxindex beaf377c..9dad29ab 100644--- a/components/view/dataroom/dataroom-view.tsx+++ b/components/view/dataroom/dataroom-view.tsx@@ -16,6 +16,7 @@ import AccessForm, {} from "@/components/view/access-form";import { useAnalytics } from "@/lib/analytics";+import { SUPPORTED_DOCUMENT_SIMPLE_TYPES } from "@/lib/constants";import { LinkWithDataroom, WatermarkConfig } from "@/lib/types";import DataroomViewer from "../DataroomViewer";@@ -35,11 +36,14 @@ type SheetData = {rowData: RowData[];};+export type TSupportedDocumentSimpleType =+ (typeof SUPPORTED_DOCUMENT_SIMPLE_TYPES)[number];+export type TDocumentData = {id: string;name: string;hasPages: boolean;- documentType: "pdf" | "notion" | "sheet";+ documentType: TSupportedDocumentSimpleType;documentVersionId: string;documentVersionNumber: number;isVertical?: boolean;diff --git a/components/view/dataroom/document-card.tsx b/components/view/dataroom/document-card.tsxindex 4cd1f23f..b2a2ff67 100644--- a/components/view/dataroom/document-card.tsx+++ b/components/view/dataroom/document-card.tsx@@ -1,12 +1,10 @@-import Image from "next/image";-import React from "react";import { useTheme } from "next-themes";import { fileIcon } from "@/lib/utils/get-file-icon";-import { TDocumentData } from "./dataroom-view";+import { TDocumentData, TSupportedDocumentSimpleType } from "./dataroom-view";type DRDocument = {dataroomDocumentId: string;@@ -57,10 +55,8 @@ export default function DocumentCard({id: document.id,name: document.name,hasPages: document.versions[0].hasPages,- documentType: document.versions[0].type as- | "pdf"- | "notion"- | "sheet",+ documentType: document.versions[0]+ .type as TSupportedDocumentSimpleType,documentVersionId: document.versions[0].id,documentVersionNumber: document.versions[0].versionNumber,isVertical: document.versions[0].isVertical,diff --git a/lib/constants.ts b/lib/constants.tsindex 68803014..d4db7d91 100644--- a/lib/constants.ts+++ b/lib/constants.ts@@ -76,10 +76,24 @@ export const LIMITS = {views: 20,};-export const SUPPORTED_DOCUMENT_TYPES = [- "application/pdf",- "application/vnd.ms-excel",- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",- "text/csv",- "application/vnd.oasis.opendocument.spreadsheet",+export const SUPPORTED_DOCUMENT_MIME_TYPES = [+ "application/pdf", // .pdf+ "application/vnd.ms-excel", // .xls+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // .xlsx+ "text/csv", // .csv+ "application/vnd.oasis.opendocument.spreadsheet", // .ods+ "application/vnd.ms-powerpoint", // .ppt+ "application/vnd.openxmlformats-officedocument.presentationml.presentation", // .pptx+ "application/vnd.oasis.opendocument.presentation", // .odp+ "application/msword", // .doc+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document", // .docx+ "application/vnd.oasis.opendocument.text", // .odt+];++export const SUPPORTED_DOCUMENT_SIMPLE_TYPES = [+ "pdf",+ "notion",+ "sheet",+ "slides",+ "docs",];diff --git a/lib/files/put-file.ts b/lib/files/put-file.tsindex ed38eaa3..cf82238f 100644--- a/lib/files/put-file.ts+++ b/lib/files/put-file.ts@@ -73,8 +73,8 @@ const putFileInS3 = async ({docId = newId("doc");}- if (!SUPPORTED_DOCUMENT_TYPES.includes(file.type)) {- throw new Error("Only PDF and Excel files are supported");+ if (!SUPPORTED_DOCUMENT_MIME_TYPES.includes(file.type)) {+ throw new Error("Only PDF, Powerpoint, Word, and Excel files are supported");}const presignedResponse = await fetch(diff --git a/lib/utils/get-content-type.ts b/lib/utils/get-content-type.tsindex ffb17789..7b1a6d6e 100644--- a/lib/utils/get-content-type.ts+++ b/lib/utils/get-content-type.ts@@ -7,6 +7,14 @@ export function getSupportedContentType(contentType: string): string | null {case "text/csv":case "application/vnd.oasis.opendocument.spreadsheet":return "sheet";+ case "application/msword":+ case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":+ case "application/vnd.oasis.opendocument.text":+ return "docs";+ case "application/vnd.ms-powerpoint":+ case "application/vnd.openxmlformats-officedocument.presentationml.presentation":+ case "application/vnd.oasis.opendocument.presentation":+ return "slides";default:return null;}@@ -26,6 +34,18 @@ export function getExtensionFromContentType(return "csv";case "application/vnd.oasis.opendocument.spreadsheet":return "ods";+ case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":+ return "docx";+ case "application/vnd.oasis.opendocument.text":+ return "odt";+ case "application/vnd.openxmlformats-officedocument.presentationml.presentation":+ return "pptx";+ case "application/vnd.oasis.opendocument.presentation":+ return "odp";+ case "application/vnd.ms-powerpoint":+ return "ppt";+ case "application/msword":+ return "doc";default:return null;}