mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 08:12:40 +10:00
object storage + full permission system + testing
Object storage now works fully, with the permission system. It still needs additional external endpoints for updating and deleting objects from the API, but it is otherwise complete. Further tasks include writing an S3 adapter.
This commit is contained in:
13
server/api/v1/object/[id]/index.get.ts
Normal file
13
server/api/v1/object/[id]/index.get.ts
Normal file
@ -0,0 +1,13 @@
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const id = getRouterParam(h3, "id");
|
||||
if (!id) throw createError({ statusCode: 400, statusMessage: "Invalid ID" });
|
||||
|
||||
const userId = await h3.context.session.getUserId(h3);
|
||||
|
||||
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;
|
||||
});
|
||||
Reference in New Issue
Block a user