mirror of
https://github.com/C4illin/ConvertX.git
synced 2026-03-03 02:17:01 +00:00
Merge commit from fork
This commit is contained in:
@@ -3,6 +3,7 @@ import db from "../db/db";
|
||||
import { WEBROOT } from "../helpers/env";
|
||||
import { uploadsDir } from "../index";
|
||||
import { userService } from "./user";
|
||||
import sanitize from "sanitize-filename";
|
||||
|
||||
export const upload = new Elysia().use(userService).post(
|
||||
"/upload",
|
||||
@@ -24,10 +25,12 @@ export const upload = new Elysia().use(userService).post(
|
||||
if (body?.file) {
|
||||
if (Array.isArray(body.file)) {
|
||||
for (const file of body.file) {
|
||||
await Bun.write(`${userUploadsDir}${file.name}`, file);
|
||||
const santizedFileName = sanitize(file.name)
|
||||
await Bun.write(`${userUploadsDir}${santizedFileName}`, file);
|
||||
}
|
||||
} else {
|
||||
await Bun.write(`${userUploadsDir}${body.file["name"]}`, body.file);
|
||||
const santizedFileName = sanitize(body.file["name"])
|
||||
await Bun.write(`${userUploadsDir}${santizedFileName}`, body.file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user