Portofolio
#feat - Create porto - Edit Porto - Upload gambar background profile - List user - Search user ## No issuue
This commit is contained in:
23
src/app/api/profile/url_foto/[url]/route.ts
Normal file
23
src/app/api/profile/url_foto/[url]/route.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import fs from "fs";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { url: string } }
|
||||
) {
|
||||
if (!fs.existsSync(`./public/profile/foto/${params.url}`)) {
|
||||
const notFile = fs.readFileSync("./public/aset/global/avatar.png");
|
||||
return new NextResponse(notFile, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const file = fs.readFileSync(`./public/profile/foto/${params.url}`);
|
||||
return new NextResponse(file, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user