url image bug patched.

This commit is contained in:
charles-gauthereau
2025-01-03 21:47:22 +01:00
parent a43878688b
commit d42d73661e
+10 -3
View File
@@ -10,6 +10,7 @@ import {checkMinioAlive, createPublicBucket, saveFileInBucket} from "@/utils/s3-
import {prisma} from "@/prisma"; import {prisma} from "@/prisma";
import {UploadedObjectInfo} from "minio/src/internal/type"; import {UploadedObjectInfo} from "minio/src/internal/type";
import {Settings} from "@prisma/client"; import {Settings} from "@prisma/client";
import {getServerUrl} from "@/utils/get-server-url";
export const uploadImageAction = userAction export const uploadImageAction = userAction
@@ -50,13 +51,19 @@ export const uploadImageAction = userAction
function getUrl(fileName:string, settings: Settings, bucketName: string):string { function getUrl(fileName:string, settings: Settings, bucketName: string):string {
if (env.NODE_ENV === "production") { if (env.NODE_ENV === "production") {
// url = `https://${env.S3_ENDPOINT}/${bucketName}/${fileName}` if(settings.storage === "s3"){
return "url" return `https://${env.S3_ENDPOINT}/${bucketName}/${fileName}`
}else if(settings.storage === "local"){
const url = getServerUrl()
return `${url}/uploads/${fileName}`
}
} else { } else {
if(settings.storage === "s3"){ if(settings.storage === "s3"){
return `http://localhost:${env.S3_PORT}/${bucketName}/${fileName}` return `http://localhost:${env.S3_PORT}/${bucketName}/${fileName}`
}else if(settings.storage === "local"){ }else if(settings.storage === "local"){
return `http://localhost:8887/uploads/${fileName}` const url = getServerUrl()
return `${url}/uploads/${fileName}`
} }
} }
} }