fix
This commit is contained in:
+4
-4
@@ -2,7 +2,7 @@ import crypto from "crypto";
|
||||
import sharp from "sharp";
|
||||
|
||||
import { AppError } from "@/lib/action-result";
|
||||
import { minioClient } from "@/lib/minio";
|
||||
import { getMinioClient } from "@/lib/minio";
|
||||
|
||||
const BUCKET = "uploads";
|
||||
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
||||
@@ -42,16 +42,16 @@ export async function uploadImage(file: File, directory: string, options: { maxW
|
||||
.toBuffer();
|
||||
|
||||
const key = `${directory}/${crypto.randomUUID()}.webp`;
|
||||
await minioClient.putObject(BUCKET, key, output, output.length, { "Content-Type": "image/webp" });
|
||||
await getMinioClient().putObject(BUCKET, key, output, output.length, { "Content-Type": "image/webp" });
|
||||
return key;
|
||||
}
|
||||
|
||||
export async function removeImage(key: string) {
|
||||
await minioClient.removeObject(BUCKET, key)
|
||||
await getMinioClient().removeObject(BUCKET, key)
|
||||
}
|
||||
|
||||
export async function getImageUrl(key: string): Promise<string> {
|
||||
return minioClient.presignedGetObject(
|
||||
return getMinioClient().presignedGetObject(
|
||||
BUCKET,
|
||||
key,
|
||||
60 * 5
|
||||
|
||||
Reference in New Issue
Block a user