MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / get

Method get

packages/hydrooj/src/handler/misc.ts:122–130  ·  view source on GitHub ↗
({ }, target: string, filename = '', expire: number, secret: string)

Source from the content-addressed store, hash-verified

120 @param('expire', Types.UnsignedInt)
121 @param('secret', Types.String)
122 async get({ }, target: string, filename = '', expire: number, secret: string) {
123 if (expire < Date.now()) throw new AccessDeniedError();
124 if (!(await this.ctx.get('storage')?.isLinkValid?.(`${target}/${expire}/${secret}`))) throw new AccessDeniedError();
125 this.response.body = await storage.get(target);
126 this.response.type = (target.endsWith('.out') || target.endsWith('.ans'))
127 ? 'text/plain'
128 : lookup(target) || 'application/octet-stream';
129 if (filename) this.response.disposition = `attachment; filename="${encodeRFC5987ValueChars(filename)}"`;
130 }
131}
132
133export class SwitchAccountHandler extends Handler {

Callers

nothing calls this directly

Calls 3

encodeRFC5987ValueCharsFunction · 0.90
isLinkValidMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected