tambahannya
This commit is contained in:
20
src/app/api/[[...slugs]]/_lib/img-del.ts
Normal file
20
src/app/api/[[...slugs]]/_lib/img-del.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
|
||||
async function imgDel({
|
||||
name,
|
||||
UPLOAD_DIR_IMAGE,
|
||||
}: {
|
||||
name: string;
|
||||
UPLOAD_DIR_IMAGE: string;
|
||||
}) {
|
||||
try {
|
||||
await fs.unlink(path.join(UPLOAD_DIR_IMAGE, name));
|
||||
return "ok";
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
export default imgDel;
|
||||
Reference in New Issue
Block a user