Test server
This commit is contained in:
BIN
public/job/15634b64-db59-43ef-ad49-e6f4e9dd1329.jpg
Normal file
BIN
public/job/15634b64-db59-43ef-ad49-e6f4e9dd1329.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -1,6 +1,8 @@
|
|||||||
import prisma from "@/app/lib/prisma";
|
import prisma from "@/app/lib/prisma";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import path from "path";
|
||||||
|
const root = process.cwd();
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
req: NextRequest,
|
req: NextRequest,
|
||||||
@@ -15,15 +17,17 @@ export async function GET(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!fs.existsSync(`./public/job/${get?.url}`)) {
|
if (!fs.existsSync(path.join(root, `public/job/${get?.url}`))) {
|
||||||
const notFile = fs.readFileSync("./public/aset/global/no-file.png");
|
const notFile = fs.readFileSync(
|
||||||
|
path.join(root, "public/aset/global/no-file.png")
|
||||||
|
);
|
||||||
return new NextResponse(notFile, {
|
return new NextResponse(notFile, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "image/png",
|
"Content-Type": "image/png",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const file = fs.readFileSync(`./public/job/${get?.url}`);
|
const file = fs.readFileSync(path.join(root, `public/job/${get?.url}`));
|
||||||
return new NextResponse(file, {
|
return new NextResponse(file, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "image/png",
|
"Content-Type": "image/png",
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ export async function adminMap_funGetOneById({ mapId }: { mapId: string }) {
|
|||||||
id: mapId,
|
id: mapId,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
|
ImageMap: true,
|
||||||
|
ImagePin: true,
|
||||||
Author: true,
|
Author: true,
|
||||||
Images: true,
|
|
||||||
Portofolio: {
|
Portofolio: {
|
||||||
include: {
|
include: {
|
||||||
MasterBidangBisnis: {
|
MasterBidangBisnis: {
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { v4 } from "uuid";
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
import { MODEL_JOB } from "../../model/interface";
|
import { MODEL_JOB } from "../../model/interface";
|
||||||
|
import path from "path";
|
||||||
|
const root = process.cwd();
|
||||||
|
|
||||||
export async function Job_funCreate(req: MODEL_JOB, file: FormData) {
|
export async function Job_funCreate(req: MODEL_JOB, file: FormData) {
|
||||||
const authorId = await user_getOneUserId();
|
const authorId = await user_getOneUserId();
|
||||||
@@ -30,7 +32,10 @@ export async function Job_funCreate(req: MODEL_JOB, file: FormData) {
|
|||||||
|
|
||||||
if (!upload) return { status: 400, message: "Gagal upload gambar" };
|
if (!upload) return { status: 400, message: "Gagal upload gambar" };
|
||||||
const uploadFolder = Buffer.from(await dataImage.arrayBuffer());
|
const uploadFolder = Buffer.from(await dataImage.arrayBuffer());
|
||||||
fs.writeFileSync(`./public/job/${upload.url}`, uploadFolder);
|
fs.writeFileSync(
|
||||||
|
path.join(root, `public/job/${upload.url}`),
|
||||||
|
uploadFolder
|
||||||
|
);
|
||||||
const createDataWithImg = await prisma.job.create({
|
const createDataWithImg = await prisma.job.create({
|
||||||
data: {
|
data: {
|
||||||
title: req.title,
|
title: req.title,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export async function map_funCreatePin({ data }: { data: any }) {
|
|||||||
namePin: data.namePin,
|
namePin: data.namePin,
|
||||||
portofolioId: data?.portofolioId,
|
portofolioId: data?.portofolioId,
|
||||||
authorId: authorId,
|
authorId: authorId,
|
||||||
imagesId: uploadImage.id,
|
imagesMapId: uploadImage.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export async function map_funEditMap({
|
|||||||
latitude: data.latitude,
|
latitude: data.latitude,
|
||||||
longitude: data.longitude,
|
longitude: data.longitude,
|
||||||
namePin: data.namePin,
|
namePin: data.namePin,
|
||||||
imagesId: uploadImage.id,
|
imagesMapId: uploadImage.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export async function map_funGetOneById({ mapId }: { mapId: string }) {
|
|||||||
latitude: true,
|
latitude: true,
|
||||||
longitude: true,
|
longitude: true,
|
||||||
authorId: true,
|
authorId: true,
|
||||||
imagesId: true,
|
imagesMapId: true,
|
||||||
Portofolio: {
|
Portofolio: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export async function map_funGetOneByPortofolioId({
|
|||||||
namePin: true,
|
namePin: true,
|
||||||
latitude: true,
|
latitude: true,
|
||||||
longitude: true,
|
longitude: true,
|
||||||
imagesId: true,
|
imagesMapId: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user