11import { PaperAdmin } from "@/db/papers" ;
22import { createPDFfromImages , compressPDF } from "@/lib/storage/pdf" ;
3- import { uploadPDF , uploadThumbnail } from "@/lib/storage/gcp" ;
3+ import { uploadPDF } from "@/lib/storage/gcp" ;
44import { connectToDatabase } from "@/lib/database/mongoose" ;
55
66const MAX_COMPRESSED_PDF_SIZE = 5 * 1024 * 1024 ; // 5MB compressed
@@ -9,18 +9,16 @@ const COMPRESS_THRESHOLD = 5 * 1024 * 1024; // 5MB
99type UploadPaperInput = {
1010 files : File [ ] ;
1111 isPdf : boolean ;
12- thumbnail : File | null ;
1312 campus : string | null ;
1413} ;
1514
1615type UploadPaperResult =
17- | { success : true ; file_url : string ; thumbnail_url : string | null }
16+ | { success : true ; file_url : string }
1817 | { success : false ; message : string ; status : number } ;
1918
2019export async function uploadPaper ( {
2120 files,
2221 isPdf,
23- thumbnail,
2422 campus,
2523} : UploadPaperInput ) : Promise < UploadPaperResult > {
2624 await connectToDatabase ( ) ;
@@ -63,15 +61,9 @@ export async function uploadPaper({
6361 const buffer = Buffer . from ( pdfBytes ) ;
6462 const file_url = await uploadPDF ( "unapproved" , buffer ) ;
6563
66- let thumbnail_url : string | null = null ;
67- if ( thumbnail ) {
68- const thumbBuffer = Buffer . from ( await thumbnail . arrayBuffer ( ) ) ;
69- thumbnail_url = await uploadThumbnail ( thumbBuffer , file_url ) ;
70- }
71-
7264 const paper = new PaperAdmin ( {
7365 file_url,
74- thumbnail_url,
66+ thumbnail_url : null ,
7567 campus,
7668 subject : null ,
7769 slot : null ,
@@ -82,5 +74,5 @@ export async function uploadPaper({
8274 } ) ;
8375 await paper . save ( ) ;
8476
85- return { success : true , file_url, thumbnail_url } ;
77+ return { success : true , file_url } ;
8678}
0 commit comments