refactor(api): 🔥 Refactor media uploader code

This commit is contained in:
Jesse Wierzbinski 2024-05-12 14:30:27 -10:00
parent 9566387273
commit 303928f960
No known key found for this signature in database
6 changed files with 80 additions and 86 deletions

View file

@ -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,