fix response pipe, remove multipart

This commit is contained in:
undefined committed 2020-08-20 17:29:46 +08:00
1 parent 65a50275b1
commit af9a8fb206
13 files changed
+70 -46

No files matched your search

+3 -1
View File
@@ -6,6 +6,7 @@ import {
} from '../error';
import * as user from '../model/user';
import * as domain from '../model/domain';
import * as system from '../model/system';
import { DOMAIN_SETTINGS, DOMAIN_SETTINGS_BY_KEY } from '../model/setting';
import { PERM, PERMS_BY_FAMILY, PRIV } from '../model/builtin';
import { gravatar } from '../lib/misc';
@@ -199,6 +200,7 @@ class DomainJoinApplicationsHandler extends ManageHandler {
if (!this.response.body.joinSettings) {
delete this.response.body.expirations[domain.JOIN_EXPIRATION_KEEP_CURRENT];
}
this.response.body.url_prefix = await system.get('server.url');
this.response.body.path = [
['Hydro', 'homepage'],
['domain', null],
@@ -207,7 +209,7 @@ class DomainJoinApplicationsHandler extends ManageHandler {
this.response.template = 'domain_join_applications.html';
}
@param('method', Types.Range(domain.JOIN_METHOD_RANGE))
@param('method', Types.Range([domain.JOIN_METHOD_NONE, domain.JOIN_METHOD_ALL, domain.JOIN_METHOD_CODE]))
@param('role', Types.String, true)
@param('expire', Types.UnsignedInt, true)
@param('invitationCode', Types.String, true)
+3 -4
View File
@@ -7,7 +7,7 @@ import * as file from '../model/file';
import * as user from '../model/user';
import * as db from '../service/db';
import {
Route, Handler, Types, param, multipart,
Route, Handler, Types, param,
} from '../service/server';
import { BadRequestError } from '../error';
@@ -19,8 +19,8 @@ class FileDownloadHandler extends Handler {
@param('name', Types.String, true)
async get(domainId: string, fileId: ObjectID, secret: string, name: string) {
if (name) name = Buffer.from(name, 'base64').toString();
this.response.attachment(name || fileId.toHexString());
this.response.body = await file.getWithSecret(fileId, secret);
const doc = await file.getWithSecret(fileId, secret);
this.response.attachment(name || fileId.toHexString(), doc);
}
}
@@ -38,7 +38,6 @@ class FileUploadHandler extends Handler {
this.response.body = { fdoc: null, usage: this.user.usage, quota: await this.getQuota() };
}
@multipart(256 * 1024)
@param('title', Types.String)
async post(domainId: string, title: string) {
if (!this.request.files.file) throw new BadRequestError();
+1 -2
View File
@@ -22,7 +22,7 @@ import * as solution from '../model/solution';
import { PERM, PRIV, CONSTANT } from '../model/builtin';
import * as bus from '../service/bus';
import {
Route, Connection, Handler, ConnectionHandler, Types, param, multipart,
Route, Connection, Handler, ConnectionHandler, Types, param,
} from '../service/server';
const parseCategory = (value: string) => flatten(value.split('+').map((e) => e.split(','))).map((e) => e.trim());
@@ -422,7 +422,6 @@ class ProblemDataUploadHandler extends ProblemManageHandler {
this.response.template = 'problem_upload.html';
}
@multipart(256 * 1024)
async post({ domainId }) {
if (!this.request.files.file) throw new ValidationError('file');
this.pdoc = await problem.setTestdata(