summaryrefslogtreecommitdiff
path: root/src/server/api/api-handler.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/api/api-handler.ts')
-rw-r--r--src/server/api/api-handler.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/server/api/api-handler.ts b/src/server/api/api-handler.ts
index 947794a20e..e716dcdc01 100644
--- a/src/server/api/api-handler.ts
+++ b/src/server/api/api-handler.ts
@@ -7,6 +7,8 @@ import { IUser } from '../../models/user';
import { IApp } from '../../models/app';
export default async (endpoint: Endpoint, ctx: Koa.Context) => {
+ const body = ctx.is('multipart/form-data') ? (ctx.req as any).body : ctx.request.body;
+
const reply = (x?: any, y?: any) => {
if (x === undefined) {
ctx.status = 204;
@@ -25,7 +27,7 @@ export default async (endpoint: Endpoint, ctx: Koa.Context) => {
// Authentication
try {
- [user, app] = await authenticate(ctx.request.body['i']);
+ [user, app] = await authenticate(body['i']);
} catch (e) {
reply(403, 'AUTHENTICATION_FAILED');
return;
@@ -35,7 +37,7 @@ export default async (endpoint: Endpoint, ctx: Koa.Context) => {
// API invoking
try {
- res = await call(endpoint, user, app, ctx.request.body, ctx.req);
+ res = await call(endpoint, user, app, body, (ctx.req as any).file);
} catch (e) {
reply(400, e);
return;