Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { MediaHelpers } from "../helpers/media.js";
|
||||
import { FileConverter } from "../converters/file.js";
|
||||
import { auth } from "../middleware/auth.js";
|
||||
export function setupEndpointsMedia(router) {
|
||||
router.get("/v1/media/:id", auth(true, [
|
||||
'write:media'
|
||||
]), async (ctx)=>{
|
||||
const file = await MediaHelpers.getMediaPackedOr404(ctx.params.id, ctx);
|
||||
ctx.body = FileConverter.encode(file);
|
||||
});
|
||||
router.put("/v1/media/:id", auth(true, [
|
||||
'write:media'
|
||||
]), async (ctx)=>{
|
||||
const file = await MediaHelpers.getMediaOr404(ctx.params.id, ctx);
|
||||
ctx.body = await MediaHelpers.updateMedia(file, ctx).then((p)=>FileConverter.encode(p));
|
||||
});
|
||||
router.post([
|
||||
"/v2/media",
|
||||
"/v1/media"
|
||||
], auth(true, [
|
||||
'write:media'
|
||||
]), async (ctx)=>{
|
||||
ctx.body = await MediaHelpers.uploadMedia(ctx).then((p)=>FileConverter.encode(p));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user