mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 22:09:16 +01:00
refactor(api): 🔥 Refactor media uploader code
This commit is contained in:
parent
9566387273
commit
303928f960
6 changed files with 80 additions and 86 deletions
|
|
@ -85,15 +85,17 @@ export default (app: Hono) =>
|
|||
: await mimeLookup(element);
|
||||
|
||||
if (!contentType.startsWith("image/")) {
|
||||
return jsonResponse(
|
||||
{
|
||||
error: `Emojis must be images (png, jpg, gif, etc.). Detected: ${contentType}`,
|
||||
},
|
||||
return errorResponse(
|
||||
`Emojis must be images (png, jpg, gif, etc.). Detected: ${contentType}`,
|
||||
422,
|
||||
);
|
||||
}
|
||||
|
||||
if (element instanceof File) {
|
||||
if (!element.name) {
|
||||
return errorResponse("File must have a name", 422);
|
||||
}
|
||||
|
||||
const media = await MediaBackend.fromBackendType(
|
||||
config.media.backend,
|
||||
config,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue