Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: uploading in welcome

Marc Seitzde922d8cdaf7
diff --git a/components/welcome/special-upload.tsx b/components/welcome/special-upload.tsx
index 35f4d1f7..7748946c 100644
--- a/components/welcome/special-upload.tsx
+++ b/components/welcome/special-upload.tsx
@@ -26,6 +26,7 @@ import {
copyToClipboard,
uploadImage,
} from "@/lib/utils";
+import { getSupportedContentType } from "@/lib/utils/get-content-type";
import Skeleton from "../Skeleton";
import { DEFAULT_LINK_PROPS, DEFAULT_LINK_TYPE } from "../links/link-sheet";
@@ -78,6 +79,16 @@ export default function DeckGeneratorUpload() {
try {
setUploading(true);
+ const contentType = getSupportedContentType(currentFile.type);
+
+ if (!contentType) {
+ setUploading(false);
+ toast.error(
+ "Unsupported file format. Please upload a PDF or Excel file.",
+ );
+ return;
+ }
+
const { type, data, numPages } = await putFile({
file: currentFile,
teamId,
@@ -90,7 +101,7 @@ export default function DeckGeneratorUpload() {
name: currentFile.name,
key: data!,
storageType: type!,
- contentType: currentFile.type,
+ contentType: contentType,
};
// create a document in the database
const response = await createDocument({ documentData, teamId, numPages });
diff --git a/components/welcome/upload.tsx b/components/welcome/upload.tsx
index 66f761e4..cdaff8c7 100644
--- a/components/welcome/upload.tsx
+++ b/components/welcome/upload.tsx
@@ -25,6 +25,7 @@ import {
copyToClipboard,
uploadImage,
} from "@/lib/utils";
+import { getSupportedContentType } from "@/lib/utils/get-content-type";
import Skeleton from "../Skeleton";
import { DEFAULT_LINK_PROPS, DEFAULT_LINK_TYPE } from "../links/link-sheet";
@@ -58,6 +59,16 @@ export default function Upload() {
try {
setUploading(true);
+ const contentType = getSupportedContentType(currentFile.type);
+
+ if (!contentType) {
+ setUploading(false);
+ toast.error(
+ "Unsupported file format. Please upload a PDF or Excel file.",
+ );
+ return;
+ }
+
const { type, data, numPages } = await putFile({
file: currentFile,
teamId,
@@ -70,7 +81,7 @@ export default function Upload() {
name: currentFile.name,
key: data!,
storageType: type!,
- contentType: currentFile.type,
+ contentType: contentType,
};
// create a document in the database
const response = await createDocument({ documentData, teamId, numPages });