mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-16 01:31:19 +10:00
16 lines
533 B
TypeScript
16 lines
533 B
TypeScript
import aclManager from "~/server/internal/acls";
|
|
|
|
export default defineEventHandler(async (h3) => {
|
|
const id = getRouterParam(h3, "id");
|
|
if (!id) throw createError({ statusCode: 400, statusMessage: "Invalid ID" });
|
|
|
|
const userId = await aclManager.getUserIdACL(h3, ["object:read"]);
|
|
|
|
const object = await h3.context.objects.fetchWithPermissions(id, userId);
|
|
if (!object)
|
|
throw createError({ statusCode: 404, statusMessage: "Object not found" });
|
|
|
|
setHeader(h3, "Content-Type", object.mime);
|
|
return object.data;
|
|
});
|