mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Working on the API route for upload and the ping. adding types for actions.
This commit is contained in:
@@ -26,7 +26,7 @@ export async function POST(
|
|||||||
const agentId = (await params).agentId
|
const agentId = (await params).agentId
|
||||||
const formData = await request.formData();
|
const formData = await request.formData();
|
||||||
const generatedId = formData.get("generatedId") as string;
|
const generatedId = formData.get("generatedId") as string;
|
||||||
|
console.log(formData)
|
||||||
|
|
||||||
|
|
||||||
if (!isUuidv4(generatedId)) {
|
if (!isUuidv4(generatedId)) {
|
||||||
@@ -75,8 +75,10 @@ export async function POST(
|
|||||||
const fileName = `${uuid}.dump`
|
const fileName = `${uuid}.dump`
|
||||||
const buffer = Buffer.from(await file.arrayBuffer());
|
const buffer = Buffer.from(await file.arrayBuffer());
|
||||||
|
|
||||||
const {success, message, filePath} = await uploadLocalPrivate(fileName, buffer)
|
console.log(buffer)
|
||||||
|
|
||||||
|
const {success, message, filePath} = await uploadLocalPrivate(fileName, buffer)
|
||||||
|
console.log(success, message, filePath)
|
||||||
if (!success){
|
if (!success){
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{error: message},
|
{error: message},
|
||||||
@@ -98,7 +100,7 @@ export async function POST(
|
|||||||
message: true,
|
message: true,
|
||||||
details: "Backup successfully uploaded"
|
details: "Backup successfully uploaded"
|
||||||
}
|
}
|
||||||
return Response.json(response)
|
return Response.json(response, {status: 200})
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
await prisma.backup.update({
|
await prisma.backup.update({
|
||||||
@@ -114,7 +116,7 @@ export async function POST(
|
|||||||
message: true,
|
message: true,
|
||||||
details: "Backup successfully updated with status failed"
|
details: "Backup successfully updated with status failed"
|
||||||
}
|
}
|
||||||
return Response.json(response)
|
return Response.json(response , {status: 200})
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user