mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix(api): 🐛 Fix local media endpoint not being correctly registered
Expected only a name, forgot about the file hash
This commit is contained in:
parent
c764cc044d
commit
2ec7e512e0
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
## With Docker/Podman
|
||||
|
||||
Docker is the recommended way to run Lysand (podman also works). To run Lysand with Docker, follow these steps:
|
||||
Docker is the recommended way to run Lysand (Podman also works). To run Lysand with Docker, follow these steps:
|
||||
|
||||
1. Download the `docker-compose.yml` file from the repository
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { z } from "zod";
|
|||
|
||||
export const meta = applyConfig({
|
||||
allowedMethods: ["GET"],
|
||||
route: "/media/:id",
|
||||
route: "/media/:id/:name",
|
||||
ratelimits: {
|
||||
max: 100,
|
||||
duration: 60,
|
||||
|
|
@ -18,7 +18,8 @@ export const meta = applyConfig({
|
|||
|
||||
export const schemas = {
|
||||
param: z.object({
|
||||
id: z.string().uuid(),
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
}),
|
||||
header: z.object({
|
||||
range: z.string().optional().default(""),
|
||||
|
|
@ -32,7 +33,7 @@ export default (app: Hono) =>
|
|||
zValidator("param", schemas.param, handleZodError),
|
||||
zValidator("header", schemas.header, handleZodError),
|
||||
async (context) => {
|
||||
const { id } = context.req.valid("param");
|
||||
const { id, name } = context.req.valid("param");
|
||||
const { range } = context.req.valid("header");
|
||||
|
||||
// parse `Range` header
|
||||
|
|
@ -45,7 +46,7 @@ export default (app: Hono) =>
|
|||
.map(Number); // [0, 100]
|
||||
|
||||
// Serve file from filesystem
|
||||
const file = Bun.file(`./uploads/${id}`);
|
||||
const file = Bun.file(`./uploads/${id}/${name}`);
|
||||
|
||||
const buffer = await file.arrayBuffer();
|
||||
|
||||
Loading…
Reference in a new issue