mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-13 20:53:45 +08:00
feat: support local storage
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { getServerSideConfig } from "@/app/config/server";
|
||||
import LocalFileStorage from "@/app/utils/local_file_storage";
|
||||
import S3FileStorage from "@/app/utils/s3_file_storage";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import S3FileStorage from "../../../utils/s3_file_storage";
|
||||
|
||||
async function handle(
|
||||
req: NextRequest,
|
||||
@@ -10,12 +12,22 @@ async function handle(
|
||||
}
|
||||
|
||||
try {
|
||||
var file = await S3FileStorage.get(params.path[0]);
|
||||
return new Response(file?.transformToWebStream(), {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
const serverConfig = getServerSideConfig();
|
||||
if (serverConfig.isStoreFileToLocal) {
|
||||
var fileBuffer = await LocalFileStorage.get(params.path[0]);
|
||||
return new Response(fileBuffer, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
} else {
|
||||
var file = await S3FileStorage.get(params.path[0]);
|
||||
return new Response(file?.transformToWebStream(), {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
return new Response("not found", {
|
||||
status: 404,
|
||||
@@ -25,5 +37,5 @@ async function handle(
|
||||
|
||||
export const GET = handle;
|
||||
|
||||
export const runtime = "edge";
|
||||
export const runtime = "nodejs";
|
||||
export const revalidate = 0;
|
||||
|
||||
Reference in New Issue
Block a user