Docker with minio

This commit is contained in:
Sean Morley
2024-06-09 18:10:17 +00:00
parent 1c7939f2b8
commit 4ed9ebc456
4 changed files with 49 additions and 5 deletions

View File

@@ -11,6 +11,25 @@ export async function POST(event: RequestEvent): Promise<Response> {
const fileExtension = contentType.split("/").pop();
const fileName = `${generateId(25)}.${fileExtension}`;
if (!fileExtension || !fileName) {
return new Response(JSON.stringify({ error: "Invalid file type" }), {
status: 400,
headers: {
"Content-Type": "application/json",
},
});
}
// check if the file is an image
if (!contentType.startsWith("image")) {
return new Response(JSON.stringify({ error: "Invalid file type" }), {
status: 400,
headers: {
"Content-Type": "application/json",
},
});
}
const fileBuffer = await event.request.arrayBuffer();
const metaData = {
"Content-Type": contentType,