Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: new file types
Marc Seitzbb93cfd03c75
diff --git a/components/documents/add-document-modal.tsx b/components/documents/add-document-modal.tsxindex 0325ccf9..9c52b396 100644--- a/components/documents/add-document-modal.tsx+++ b/components/documents/add-document-modal.tsx@@ -263,6 +263,24 @@ export function AddDocumentModal({contentType = "application/vnd.ms-excel.sheet.macroEnabled.12";}+ if (+ currentFile.name.endsWith(".tif") ||+ currentFile.name.endsWith(".tiff")+ ) {+ supportedFileType = "other";+ contentType = "image/tiff";+ }++ if (currentFile.name.endsWith(".ecw")) {+ supportedFileType = "other";+ contentType = "image/x-ecw";+ }++ if (currentFile.name.endsWith(".bak")) {+ supportedFileType = "other";+ contentType = "application/x-bak";+ }+if (!supportedFileType) {setUploading(false);toast.error(diff --git a/components/upload-zone.tsx b/components/upload-zone.tsxindex 26629c8b..69f1b288 100644--- a/components/upload-zone.tsx+++ b/components/upload-zone.tsx@@ -618,6 +618,24 @@ export default function UploadZone({contentType = `application/vnd.google-earth.${uploadResult.fileName.endsWith(".kml") ? "kml+xml" : "kmz"}`;}+ if (+ uploadResult.fileName.endsWith(".tif") ||+ uploadResult.fileName.endsWith(".tiff")+ ) {+ supportedFileType = "other";+ contentType = "image/tiff";+ }++ if (uploadResult.fileName.endsWith(".ecw")) {+ supportedFileType = "other";+ contentType = "image/x-ecw";+ }++ if (uploadResult.fileName.endsWith(".bak")) {+ supportedFileType = "other";+ contentType = "application/x-bak";+ }+const documentData: DocumentData = {key: uploadResult.id,supportedFileType: supportedFileType,diff --git a/components/viewer-upload-zone.tsx b/components/viewer-upload-zone.tsxindex d8ea275e..0b9a9cb8 100644--- a/components/viewer-upload-zone.tsx+++ b/components/viewer-upload-zone.tsx@@ -109,6 +109,24 @@ export default function ViewerUploadZone({contentType = "application/vnd.ms-excel.sheet.macroEnabled.12";}+ if (+ uploadResult.fileName.endsWith(".tif") ||+ uploadResult.fileName.endsWith(".tiff")+ ) {+ supportedFileType = "other";+ contentType = "image/tiff";+ }++ if (uploadResult.fileName.endsWith(".ecw")) {+ supportedFileType = "other";+ contentType = "image/x-ecw";+ }++ if (uploadResult.fileName.endsWith(".bak")) {+ supportedFileType = "other";+ contentType = "application/x-bak";+ }+const documentData: DocumentData = {key: uploadResult.id,supportedFileType: supportedFileType,diff --git a/lib/api/documents/process-document.ts b/lib/api/documents/process-document.tsindex 0ec041b1..7acc60e8 100644--- a/lib/api/documents/process-document.ts+++ b/lib/api/documents/process-document.ts@@ -119,16 +119,18 @@ export const processDocument = async ({},});- const isLogFile = name.toLowerCase().endsWith(".log");+ const isDownloadOnlyByExtension =+ /\.(log|err|prj|jgw|tif|tiff|ecw|bak)$/i.test(name);// determine if the document is download onlyconst isDownloadOnly =type === "zip" ||type === "map" ||type === "email" ||+ type === "other" ||contentType === "text/tab-separated-values" ||type === "cad" ||- isLogFile;+ isDownloadOnlyByExtension;// Save data to the databaseconst document = await prisma.document.create({@@ -198,7 +200,10 @@ export const processDocument = async ({concurrencyKey: teamId,},);- } else if ((type === "docs" || type === "slides") && !isLogFile) {+ } else if (+ (type === "docs" || type === "slides") &&+ !isDownloadOnlyByExtension+ ) {await convertFilesToPdfTask.trigger({documentId: document.id,diff --git a/lib/api/links/bulk-import.ts b/lib/api/links/bulk-import.tsindex 8d855636..b41034f0 100644--- a/lib/api/links/bulk-import.ts+++ b/lib/api/links/bulk-import.ts@@ -19,12 +19,6 @@ import {} from "@/lib/utils";import { sendLinkCreatedWebhook } from "@/lib/webhook/triggers/link-created";-export const bulkImportConfig = {- // Allow background work to flush after the response.- supportsResponseStreaming: true,- maxDuration: 120,-};-// Reused from `pages/api/webhooks/services/[...path]/index.ts` so the CSV// importer accepts the same option set users already configure through the// incoming-webhooks API.diff --git a/lib/constants.ts b/lib/constants.tsindex 116e205d..47601953 100644--- a/lib/constants.ts+++ b/lib/constants.ts@@ -83,10 +83,13 @@ export const SUPPORTED_DOCUMENT_MIME_TYPES = ["application/vnd.oasis.opendocument.text", // .odt"application/rtf", // .rtf"text/rtf", // .rtf- "text/plain", // .txt+ "text/plain", // .txt, .log, .err, .prj, .jgw"text/markdown", // .md"image/vnd.dwg", // .dwg"image/vnd.dxf", // .dxf+ "image/tiff", // .tif, .tiff+ "image/x-ecw", // .ecw (custom - GIS raster, no standard MIME)+ "application/x-bak", // .bak (custom - generic backup file)"image/png", // .png"image/jpeg", // .jpeg"image/jpg", // .jpg@@ -104,6 +107,7 @@ export const SUPPORTED_DOCUMENT_MIME_TYPES = ["application/vnd.google-earth.kml+xml", // .kml"application/vnd.google-earth.kmz", // .kmz"application/vnd.ms-outlook", // .msg+ "message/rfc822", // .eml];// Upload configurations for different plan types and contexts@@ -137,9 +141,12 @@ export const FULL_PLAN_ACCEPTED_FILE_TYPES = {"application/vnd.oasis.opendocument.text": [], // ".odt""application/rtf": [], // ".rtf""text/rtf": [], // ".rtf"- "text/plain": [".txt", ".log"], // ".txt", ".log"+ "text/plain": [".txt", ".log", ".err", ".prj", ".jgw"], // ".txt", ".log", ".err", ".prj", ".jgw""image/vnd.dwg": [".dwg"], // ".dwg""image/vnd.dxf": [".dxf"], // ".dxf"+ "image/tiff": [".tif", ".tiff"], // ".tif", ".tiff"+ "image/x-ecw": [".ecw"], // ".ecw"+ "application/x-bak": [".bak"], // ".bak""image/png": [], // ".png""image/jpeg": [], // ".jpeg""image/jpg": [], // ".jpg"@@ -157,6 +164,7 @@ export const FULL_PLAN_ACCEPTED_FILE_TYPES = {"application/vnd.google-earth.kml+xml": [".kml"], // ".kml""application/vnd.google-earth.kmz": [".kmz"], // ".kmz""application/vnd.ms-outlook": [".msg"], // ".msg"+ "message/rfc822": [".eml"], // ".eml"};export const VIEWER_ACCEPTED_FILE_TYPES = {@@ -178,13 +186,17 @@ export const VIEWER_ACCEPTED_FILE_TYPES = {"application/vnd.oasis.opendocument.text": [], // ".odt""application/rtf": [], // ".rtf""text/rtf": [], // ".rtf"- "text/plain": [".txt", ".log"], // ".txt", ".log"+ "text/plain": [".txt", ".log", ".err", ".prj", ".jgw"], // ".txt", ".log", ".err", ".prj", ".jgw"+ "image/tiff": [".tif", ".tiff"], // ".tif", ".tiff"+ "image/x-ecw": [".ecw"], // ".ecw"+ "application/x-bak": [".bak"], // ".bak""image/png": [], // ".png""image/jpeg": [], // ".jpeg""image/jpg": [], // ".jpg""application/zip": [".zip"], // ".zip""application/x-zip-compressed": [".zip"], // ".zip""application/vnd.ms-outlook": [".msg"], // ".msg"+ "message/rfc822": [".eml"], // ".eml"};export const SUPPORTED_DOCUMENT_SIMPLE_TYPES = [@@ -200,6 +212,7 @@ export const SUPPORTED_DOCUMENT_SIMPLE_TYPES = ["video","map","email",+ "other",] as const;export const VIDEO_EVENT_TYPES = [diff --git a/lib/utils/get-content-type.ts b/lib/utils/get-content-type.tsindex 7b8e9af0..7be02513 100644--- a/lib/utils/get-content-type.ts+++ b/lib/utils/get-content-type.ts@@ -46,7 +46,12 @@ export function getSupportedContentType(contentType: string): string | null {case "application/vnd.google-earth.kmz":return "map";case "application/vnd.ms-outlook":+ case "message/rfc822":return "email";+ case "image/tiff":+ case "image/x-ecw":+ case "application/x-bak":+ return "other";default:return null;}@@ -122,6 +127,14 @@ export function getExtensionFromContentType(return "kmz";case "application/vnd.ms-outlook":return "msg";+ case "message/rfc822":+ return "eml";+ case "image/tiff":+ return "tiff";+ case "image/x-ecw":+ return "ecw";+ case "application/x-bak":+ return "bak";default:return null;}diff --git a/pages/api/teams/[teamId]/datarooms/[id]/links/bulk.ts b/pages/api/teams/[teamId]/datarooms/[id]/links/bulk.tsindex f6f134bd..38c2c974 100644--- a/pages/api/teams/[teamId]/datarooms/[id]/links/bulk.ts+++ b/pages/api/teams/[teamId]/datarooms/[id]/links/bulk.ts@@ -1,11 +1,11 @@import { NextApiRequest, NextApiResponse } from "next";-import {- bulkImportConfig,- handleBulkLinkImport,-} from "@/lib/api/links/bulk-import";+import { handleBulkLinkImport } from "@/lib/api/links/bulk-import";-export const config = bulkImportConfig;+export const config = {+ supportsResponseStreaming: true,+ maxDuration: 120,+};export default async function handle(req: NextApiRequest,diff --git a/pages/api/teams/[teamId]/documents/[id]/links/bulk.ts b/pages/api/teams/[teamId]/documents/[id]/links/bulk.tsindex f92445f0..d81524dc 100644--- a/pages/api/teams/[teamId]/documents/[id]/links/bulk.ts+++ b/pages/api/teams/[teamId]/documents/[id]/links/bulk.ts@@ -1,11 +1,11 @@import { NextApiRequest, NextApiResponse } from "next";-import {- bulkImportConfig,- handleBulkLinkImport,-} from "@/lib/api/links/bulk-import";+import { handleBulkLinkImport } from "@/lib/api/links/bulk-import";-export const config = bulkImportConfig;+export const config = {+ supportsResponseStreaming: true,+ maxDuration: 120,+};export default async function handle(req: NextApiRequest,diff --git a/pages/api/teams/[teamId]/documents/[id]/versions/index.ts b/pages/api/teams/[teamId]/documents/[id]/versions/index.tsindex b55c1941..db2c51c7 100644--- a/pages/api/teams/[teamId]/documents/[id]/versions/index.ts+++ b/pages/api/teams/[teamId]/documents/[id]/versions/index.ts@@ -154,9 +154,13 @@ export default async function handle(},});- const isLogFile = url.toLowerCase().endsWith(".log");+ const isDownloadOnlyByExtension =+ /\.(log|err|prj|jgw|tif|tiff|ecw|bak)$/i.test(url);- if ((type === "docs" || type === "slides") && !isLogFile) {+ if (+ (type === "docs" || type === "slides") &&+ !isDownloadOnlyByExtension+ ) {await convertFilesToPdfTask.trigger({documentVersionId: version.id,diff --git a/pages/api/teams/[teamId]/documents/agreement.ts b/pages/api/teams/[teamId]/documents/agreement.tsindex abe5d020..500c9078 100644--- a/pages/api/teams/[teamId]/documents/agreement.ts+++ b/pages/api/teams/[teamId]/documents/agreement.ts@@ -130,9 +130,10 @@ export default async function handle(},});- const isLogFile = name.toLowerCase().endsWith(".log");+ const isDownloadOnlyByExtension =+ /\.(log|err|prj|jgw|tif|tiff|ecw|bak)$/i.test(name);- if (type === "docs" && !isLogFile) {+ if (type === "docs" && !isDownloadOnlyByExtension) {await convertFilesToPdfTask.trigger({documentId: document.id,