Merge commit from fork
This commit is contained in:
parent
d165f11798
commit
550f472451
1 changed files with 5 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue