feat: support custom s3 service

This commit is contained in:
Hk-Gosuto
2023-12-10 21:02:49 +08:00
parent eb7711f832
commit b84da5e120
6 changed files with 88 additions and 35 deletions

View File

@@ -1,6 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "../../auth";
import S3FileStorage from "../../../utils/r2_file_storage";
import S3FileStorage from "../../../utils/s3_file_storage";
async function handle(
req: NextRequest,
@@ -10,13 +9,6 @@ async function handle(
return NextResponse.json({ body: "OK" }, { status: 200 });
}
// const authResult = auth(req);
// if (authResult.error) {
// return NextResponse.json(authResult, {
// status: 401,
// });
// }
try {
var file = await S3FileStorage.get(params.path[0]);
return new Response(file?.transformToWebStream(), {
@@ -34,3 +26,4 @@ async function handle(
export const GET = handle;
export const runtime = "edge";
export const revalidate = 0;