Save current image generation workspace
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { persistUploadedImageFile } from "@/lib/server/storage/image-file-storage";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const formData = await request.formData();
|
||||
const image = formData.get("image");
|
||||
|
||||
if (!(image instanceof File)) {
|
||||
return NextResponse.json({ error: "缺少图片文件" }, { status: 400 });
|
||||
}
|
||||
|
||||
const buffer = Buffer.from(await image.arrayBuffer());
|
||||
const id = crypto.randomUUID();
|
||||
const persisted = persistUploadedImageFile(id, image.name || "canvas-upload.png", buffer);
|
||||
|
||||
return NextResponse.json({
|
||||
item: {
|
||||
id,
|
||||
imageUrl: persisted.imageUrl,
|
||||
filePath: persisted.filePath,
|
||||
fileName: persisted.fileName,
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user