Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: support xlsb, sav, and ESRI shapefile bundle as download-only
Marc Seitz113cbb035382
diff --git a/lib/api/documents/process-document.ts b/lib/api/documents/process-document.tsindex f06ebee9..e0b234fc 100644--- a/lib/api/documents/process-document.ts+++ b/lib/api/documents/process-document.ts@@ -127,7 +127,9 @@ export const processDocument = async ({: null;const isDownloadOnlyByExtension =- /\.(log|err|prj|jgw|tif|tiff|ecw|bak)$/i.test(name);+ /\.(log|err|prj|jgw|tif|tiff|ecw|bak|xlsb|sav|shp|shx|dbf|sbn|sbx|qix|cpg)$/i.test(+ name,+ );// determine if the document is download onlyconst isDownloadOnly =diff --git a/lib/constants.ts b/lib/constants.tsindex 47601953..8a4a2af4 100644--- a/lib/constants.ts+++ b/lib/constants.ts@@ -70,6 +70,7 @@ export const SUPPORTED_DOCUMENT_MIME_TYPES = ["application/vnd.ms-excel", // .xls"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // .xlsx"application/vnd.ms-excel.sheet.macroEnabled.12", // .xlsm+ "application/vnd.ms-excel.sheet.binary.macroEnabled.12", // .xlsb"text/csv", // .csv"text/tab-separated-values", // .tsv"application/vnd.oasis.opendocument.spreadsheet", // .ods@@ -83,13 +84,20 @@ export const SUPPORTED_DOCUMENT_MIME_TYPES = ["application/vnd.oasis.opendocument.text", // .odt"application/rtf", // .rtf"text/rtf", // .rtf- "text/plain", // .txt, .log, .err, .prj, .jgw+ "text/plain", // .txt, .log, .err, .prj, .jgw, .cpg"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)+ "application/x-spss-sav", // .sav (SPSS Statistics data file, no IANA MIME)+ "application/x-esri-shape", // .shp (ESRI Shapefile geometry, custom - no standard MIME)+ "application/x-esri-shape-index", // .shx (ESRI Shapefile index, custom)+ "application/x-dbf", // .dbf (dBase attribute table, custom - de facto)+ "application/x-esri-sbn", // .sbn (ESRI spatial bin index, custom)+ "application/x-esri-sbx", // .sbx (ESRI spatial bin index, custom)+ "application/x-mapserver-qix", // .qix (MapServer/GDAL quadtree spatial index, custom)"image/png", // .png"image/jpeg", // .jpeg"image/jpg", // .jpg@@ -127,6 +135,7 @@ export const FULL_PLAN_ACCEPTED_FILE_TYPES = {"application/vnd.ms-excel": [], // ".xls""application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [], // ".xlsx""application/vnd.ms-excel.sheet.macroEnabled.12": [".xlsm"], // ".xlsm"+ "application/vnd.ms-excel.sheet.binary.macroEnabled.12": [".xlsb"], // ".xlsb""text/csv": [], // ".csv""text/tab-separated-values": [".tsv"], // ".tsv""application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"@@ -141,12 +150,19 @@ export const FULL_PLAN_ACCEPTED_FILE_TYPES = {"application/vnd.oasis.opendocument.text": [], // ".odt""application/rtf": [], // ".rtf""text/rtf": [], // ".rtf"- "text/plain": [".txt", ".log", ".err", ".prj", ".jgw"], // ".txt", ".log", ".err", ".prj", ".jgw"+ "text/plain": [".txt", ".log", ".err", ".prj", ".jgw", ".cpg"], // ".txt", ".log", ".err", ".prj", ".jgw", ".cpg""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"+ "application/x-spss-sav": [".sav"], // ".sav"+ "application/x-esri-shape": [".shp"], // ".shp"+ "application/x-esri-shape-index": [".shx"], // ".shx"+ "application/x-dbf": [".dbf"], // ".dbf"+ "application/x-esri-sbn": [".sbn"], // ".sbn"+ "application/x-esri-sbx": [".sbx"], // ".sbx"+ "application/x-mapserver-qix": [".qix"], // ".qix""image/png": [], // ".png""image/jpeg": [], // ".jpeg""image/jpg": [], // ".jpg"@@ -172,6 +188,7 @@ export const VIEWER_ACCEPTED_FILE_TYPES = {"application/vnd.ms-excel": [], // ".xls""application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [], // ".xlsx""application/vnd.ms-excel.sheet.macroEnabled.12": [".xlsm"], // ".xlsm"+ "application/vnd.ms-excel.sheet.binary.macroEnabled.12": [".xlsb"], // ".xlsb""text/csv": [], // ".csv""text/tab-separated-values": [".tsv"], // ".tsv""application/vnd.oasis.opendocument.spreadsheet": [], // ".ods"@@ -186,10 +203,17 @@ export const VIEWER_ACCEPTED_FILE_TYPES = {"application/vnd.oasis.opendocument.text": [], // ".odt""application/rtf": [], // ".rtf""text/rtf": [], // ".rtf"- "text/plain": [".txt", ".log", ".err", ".prj", ".jgw"], // ".txt", ".log", ".err", ".prj", ".jgw"+ "text/plain": [".txt", ".log", ".err", ".prj", ".jgw", ".cpg"], // ".txt", ".log", ".err", ".prj", ".jgw", ".cpg""image/tiff": [".tif", ".tiff"], // ".tif", ".tiff""image/x-ecw": [".ecw"], // ".ecw""application/x-bak": [".bak"], // ".bak"+ "application/x-spss-sav": [".sav"], // ".sav"+ "application/x-esri-shape": [".shp"], // ".shp"+ "application/x-esri-shape-index": [".shx"], // ".shx"+ "application/x-dbf": [".dbf"], // ".dbf"+ "application/x-esri-sbn": [".sbn"], // ".sbn"+ "application/x-esri-sbx": [".sbx"], // ".sbx"+ "application/x-mapserver-qix": [".qix"], // ".qix""image/png": [], // ".png""image/jpeg": [], // ".jpeg""image/jpg": [], // ".jpg"diff --git a/lib/files/put-file.ts b/lib/files/put-file.tsindex a36ccade..9dfbce23 100644--- a/lib/files/put-file.ts+++ b/lib/files/put-file.ts@@ -97,11 +97,27 @@ const putFileInS3 = async ({docId = newId("doc");}+ // Some formats either have no browser-known MIME (binary GIS/stats) or+ // browsers return inconsistent MIMEs (older Office macro-enabled / binary).+ // Fall back to extension matching for those before rejecting the upload.+ const EXTENSION_FALLBACKS = [+ ".dwg",+ ".dxf",+ ".xlsm",+ ".xlsb",+ ".sav",+ ".shp",+ ".shx",+ ".dbf",+ ".sbn",+ ".sbx",+ ".qix",+ ".cpg",+ ];+ const lowerName = file.name.toLowerCase();if (!SUPPORTED_DOCUMENT_MIME_TYPES.includes(file.type) &&- !file.name.endsWith(".dwg") &&- !file.name.endsWith(".dxf") &&- !file.name.endsWith(".xlsm")+ !EXTENSION_FALLBACKS.some((ext) => lowerName.endsWith(ext))) {throw new Error("Only PDF, Powerpoint, Word, and Excel, ZIP files are supported",diff --git a/lib/utils/get-content-type.ts b/lib/utils/get-content-type.tsindex b0253c34..04da71c2 100644--- a/lib/utils/get-content-type.ts+++ b/lib/utils/get-content-type.ts@@ -5,6 +5,7 @@ export function getSupportedContentType(contentType: string): string | null {case "application/vnd.ms-excel":case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":case "application/vnd.ms-excel.sheet.macroEnabled.12":+ case "application/vnd.ms-excel.sheet.binary.macroEnabled.12":case "text/csv":case "text/tab-separated-values":case "application/vnd.oasis.opendocument.spreadsheet":@@ -44,6 +45,12 @@ export function getSupportedContentType(contentType: string): string | null {return "video";case "application/vnd.google-earth.kml+xml":case "application/vnd.google-earth.kmz":+ case "application/x-esri-shape":+ case "application/x-esri-shape-index":+ case "application/x-dbf":+ case "application/x-esri-sbn":+ case "application/x-esri-sbx":+ case "application/x-mapserver-qix":return "map";case "application/vnd.ms-outlook":case "message/rfc822":@@ -51,6 +58,7 @@ export function getSupportedContentType(contentType: string): string | null {case "image/tiff":case "image/x-ecw":case "application/x-bak":+ case "application/x-spss-sav":return "other";default:return null;@@ -69,6 +77,8 @@ export function getExtensionFromContentType(return "xlsx";case "application/vnd.ms-excel.sheet.macroEnabled.12":return "xlsm";+ case "application/vnd.ms-excel.sheet.binary.macroEnabled.12":+ return "xlsb";case "text/csv":return "csv";case "text/tab-separated-values":@@ -135,6 +145,20 @@ export function getExtensionFromContentType(return "ecw";case "application/x-bak":return "bak";+ case "application/x-spss-sav":+ return "sav";+ case "application/x-esri-shape":+ return "shp";+ case "application/x-esri-shape-index":+ return "shx";+ case "application/x-dbf":+ return "dbf";+ case "application/x-esri-sbn":+ return "sbn";+ case "application/x-esri-sbx":+ return "sbx";+ case "application/x-mapserver-qix":+ return "qix";default:return null;}