fix(api): fix double period in uploaded file name

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2023-10-12 22:56:50 -04:00
parent c925534eb4
commit e9c4de973a
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

View File

@ -2,6 +2,7 @@ import { writeFileSync } from "fs";
import { extname } from "path"; import { extname } from "path";
import { v4 } from "uuid"; import { v4 } from "uuid";
import { ContentFilenameRegex } from "~/lib/server/constants"; import { ContentFilenameRegex } from "~/lib/server/constants";
import { log } from "~/lib/server/logger";
import isLoggedIn from "~/lib/server/middlewareButNotReally/isLoggedIn"; import isLoggedIn from "~/lib/server/middlewareButNotReally/isLoggedIn";
export default eventHandler(async (ev) => { export default eventHandler(async (ev) => {
@ -13,8 +14,9 @@ export default eventHandler(async (ev) => {
statusCode: 400, statusCode: 400,
message: noMultipart, message: noMultipart,
}); });
log.debug("woooo", { label: "http/upload" });
let file = mpd[0]; let file = mpd[0];
log.debug(mpd[0].filename!, { label: "http/upload" });
if (!file) { if (!file) {
throw createError({ throw createError({
statusCode: 400, statusCode: 400,
@ -27,7 +29,7 @@ export default eventHandler(async (ev) => {
message: "unsupported file type!", message: "unsupported file type!",
}); });
} }
let b = `${v4()}.${extname(file.filename!)}`; let b = `${v4()}${extname(file.filename!)}`;
writeFileSync(`tmp/${b}`, file.data); writeFileSync(`tmp/${b}`, file.data);
return { return {
success: true, success: true,