Skip to content

Commit d93a3c4

Browse files
Won't raise an error even if paper allready in db
1 parent cb96982 commit d93a3c4

File tree

1 file changed

+3
-39
lines changed

1 file changed

+3
-39
lines changed

src/app/api/admin/route.ts

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import { PDFDocument } from "pdf-lib";
44
import { connectToDatabase } from "@/lib/mongoose";
55
import cloudinary from "cloudinary";
66
import {
7-
type IAdminUpload,
8-
type ConverttoPDFResponse,
7+
98
CloudinaryUploadResult,
109
} from "@/interface";
1110
import Paper from "@/db/papers";
12-
import { handleAPIError } from "@/util/error";
13-
11+
// TODO: REMOVE THUMBNAIL FROM admin-buffer DB
1412
cloudinary.v2.config({
1513
cloud_name: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME,
1614
api_key: process.env.CLOUDINARY_API_KEY,
@@ -36,18 +34,7 @@ export async function POST(req: Request) {
3634
let finalUrl: string | undefined = "";
3735
let public_id_cloudinary: string | undefined = "";
3836
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+
5138
if (!files || files.length === 0) {
5239
return NextResponse.json(
5340
{ error: "No files received." },
@@ -103,30 +90,7 @@ export async function POST(req: Request) {
10390
}
10491
}
10592

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-
// });
12193

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-
// }
13094
async function uploadPDFFile(file: File | ArrayBuffer, uploadPreset: string) {
13195
let bytes;
13296
if(file instanceof File) //for pdf

0 commit comments

Comments
 (0)