Skip to content

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

trigger job from upload document

Marc Seitz151dce395564
diff --git a/pages/api/documents/index.ts b/pages/api/documents/index.ts
index 44f02a3c..3c21ec1b 100644
--- a/pages/api/documents/index.ts
+++ b/pages/api/documents/index.ts
@@ -5,6 +5,7 @@ import { authOptions } from "../auth/[...nextauth]";
import { CustomUser } from "@/lib/types";
import { getExtension, log } from "@/lib/utils";
import { identifyUser, trackAnalytics } from "@/lib/analytics";
+import { client } from "@/trigger";
export default async function handle(
req: NextApiRequest,
@@ -110,6 +111,12 @@ export default async function handle(
customDomain: null,
});
+ // trigger document uploaded event to trigger convert-pdf-to-image job
+ await client.sendEvent({
+ name: "document.uploaded",
+ payload: { documentVersionId: document.versions[0].id },
+ });
+
res.status(201).json(document);
} catch (error) {
log(`Failed to create document. Error: \n\n ${error}`)