@@ -4,13 +4,11 @@ import { PDFDocument } from "pdf-lib";
4
4
import { connectToDatabase } from "@/lib/mongoose" ;
5
5
import cloudinary from "cloudinary" ;
6
6
import {
7
- type IAdminUpload ,
8
- type ConverttoPDFResponse ,
7
+
9
8
CloudinaryUploadResult ,
10
9
} from "@/interface" ;
11
10
import Paper from "@/db/papers" ;
12
- import { handleAPIError } from "@/util/error" ;
13
-
11
+ // TODO: REMOVE THUMBNAIL FROM admin-buffer DB
14
12
cloudinary . v2 . config ( {
15
13
cloud_name : process . env . NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME ,
16
14
api_key : process . env . CLOUDINARY_API_KEY ,
@@ -36,18 +34,7 @@ export async function POST(req: Request) {
36
34
let finalUrl : string | undefined = "" ;
37
35
let public_id_cloudinary : string | undefined = "" ;
38
36
let thumbnailUrl : string | undefined = "" ;
39
- const existingPaper = await Paper . findOne ( {
40
- subject,
41
- slot,
42
- year,
43
- exam,
44
- } ) ;
45
- if ( existingPaper ) {
46
- return NextResponse . json (
47
- { message : "Paper already exists" } ,
48
- { status : 409 } ,
49
- ) ;
50
- }
37
+
51
38
if ( ! files || files . length === 0 ) {
52
39
return NextResponse . json (
53
40
{ error : "No files received." } ,
@@ -103,30 +90,7 @@ export async function POST(req: Request) {
103
90
}
104
91
}
105
92
106
- // export async function DELETE(req: Request) {
107
- // try {
108
- // const url = new URL(req.url);
109
- // const public_id = url.searchParams.get("public_id");
110
- // const type = url.searchParams.get("type");
111
-
112
- // if (!public_id || !type) {
113
- // return NextResponse.json(
114
- // { message: "Missing parameters: public_id or type" },
115
- // { status: 400 },
116
- // );
117
- // }
118
- // await cloudinary.v2.uploader.destroy(public_id, {
119
- // type: type,
120
- // });
121
93
122
- // return NextResponse.json({ message: "Asset deleted successfully" });
123
- // } catch (error) {
124
- // return NextResponse.json(
125
- // { message: "Failed to delete asset", error },
126
- // { status: 500 },
127
- // );
128
- // }
129
- // }
130
94
async function uploadPDFFile ( file : File | ArrayBuffer , uploadPreset : string ) {
131
95
let bytes ;
132
96
if ( file instanceof File ) //for pdf
0 commit comments