feat: download query on /r/
This commit is contained in:
parent
5e6c53432b
commit
2adb355183
1 changed files with 3 additions and 1 deletions
|
@ -8,6 +8,8 @@ function rawFileDecorator(fastify: FastifyInstance, _, done) {
|
|||
done();
|
||||
|
||||
async function rawFile(this: FastifyReply, id: string) {
|
||||
const { download } = this.request.query as { download?: string };
|
||||
|
||||
const data = await this.server.datasource.get(id);
|
||||
if (!data) return this.notFound();
|
||||
|
||||
|
@ -15,7 +17,7 @@ function rawFileDecorator(fastify: FastifyInstance, _, done) {
|
|||
const size = await this.server.datasource.size(id);
|
||||
|
||||
this.header('Content-Length', size);
|
||||
this.header('Content-Type', mimetype);
|
||||
this.header('Content-Type', download ? 'application/octet-stream' : mimetype);
|
||||
return this.send(data);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue