upd: api mobile

Deskripsi:
- api project upload tambah file
- api project delete file
- api project tambah data upload file

- api project check file

NO Issues
This commit is contained in:
amel
2025-05-20 14:39:46 +08:00
parent 2de14e7e0e
commit 0f6677f142
2 changed files with 27 additions and 28 deletions

View File

@@ -159,34 +159,34 @@ export async function POST(request: Request, context: { params: { id: string } }
}
if (cekFile) {
console.log('masuk file')
// for (var pair of body.entries()) {
// if (String(pair[0]).substring(0, 4) == "file") {
// const file = body.get(pair[0]) as File
// const fExt = file.name.split(".").pop()
// const fName = file.name.replace("." + fExt, "")
body.delete("data")
for (var pair of body.entries()) {
if (String(pair[0]).substring(0, 4) == "file") {
const file = body.get(pair[0]) as File
const fExt = file.name.split(".").pop()
const fName = file.name.replace("." + fExt, "")
// const upload = await funUploadFile({ file: file, dirId: DIR.project })
// if (upload.success) {
// const insertToTable = await prisma.projectFile.create({
// data: {
// idStorage: upload.data.id,
// idProject: id,
// name: fName,
// extension: String(fExt),
const upload = await funUploadFile({ file: file, dirId: DIR.project })
if (upload.success) {
const insertToTable = await prisma.projectFile.create({
data: {
idStorage: upload.data.id,
idProject: id,
name: fName,
extension: String(fExt),
// },
// select: {
// id: true
// }
// })
// }
// }
// }
},
select: {
id: true
}
})
}
}
}
}
// // create log user
// const log = await createLogUserMobile({ act: 'CREATE', desc: 'User menambah file kegiatan', table: 'project', data: String(id), user: user.id })
// create log user
const log = await createLogUserMobile({ act: 'CREATE', desc: 'User menambah file kegiatan', table: 'project', data: String(id), user: user.id })
return NextResponse.json({ success: true, message: "Berhasil mengupload file kegiatan" }, { status: 200 });
} catch (error) {