fix: s3 integration + custom s3 (minio) support
This commit is contained in:
parent
946eed3773
commit
836dc10c2b
|
@ -14,7 +14,9 @@ RE_ARCHIVE_LIMIT=
|
|||
SPACES_KEY=
|
||||
SPACES_SECRET=
|
||||
SPACES_ENDPOINT=
|
||||
SPACES_BUCKET_NAME=
|
||||
SPACES_REGION=
|
||||
SPACES_FORCE_PATH_STYLE=
|
||||
|
||||
# SMTP Settings
|
||||
NEXT_PUBLIC_EMAIL_PROVIDER=
|
||||
|
|
|
@ -14,7 +14,7 @@ export default async function createFile({
|
|||
}) {
|
||||
if (s3Client) {
|
||||
const bucketParams: PutObjectCommandInput = {
|
||||
Bucket: process.env.BUCKET_NAME,
|
||||
Bucket: process.env.SPACES_BUCKET_NAME,
|
||||
Key: filePath,
|
||||
Body: isBase64 ? Buffer.from(data as string, "base64") : data,
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ import removeFile from "./removeFile";
|
|||
|
||||
export default async function moveFile(from: string, to: string) {
|
||||
if (s3Client) {
|
||||
const Bucket = process.env.BUCKET_NAME;
|
||||
const Bucket = process.env.SPACES_BUCKET_NAME;
|
||||
|
||||
const copyParams = {
|
||||
Bucket: Bucket,
|
||||
|
|
|
@ -20,7 +20,7 @@ export default async function readFile(filePath: string) {
|
|||
|
||||
if (s3Client) {
|
||||
const bucketParams: GetObjectCommandInput = {
|
||||
Bucket: process.env.BUCKET_NAME,
|
||||
Bucket: process.env.SPACES_BUCKET_NAME,
|
||||
Key: filePath,
|
||||
};
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import { PutObjectCommandInput, DeleteObjectCommand } from "@aws-sdk/client-s3";
|
|||
export default async function removeFile({ filePath }: { filePath: string }) {
|
||||
if (s3Client) {
|
||||
const bucketParams: PutObjectCommandInput = {
|
||||
Bucket: process.env.BUCKET_NAME,
|
||||
Bucket: process.env.SPACES_BUCKET_NAME,
|
||||
Key: filePath,
|
||||
};
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ async function emptyS3Directory(bucket: string, dir: string) {
|
|||
export default async function removeFolder({ filePath }: { filePath: string }) {
|
||||
if (s3Client) {
|
||||
try {
|
||||
await emptyS3Directory(process.env.BUCKET_NAME as string, filePath);
|
||||
await emptyS3Directory(process.env.SPACES_BUCKET_NAME as string, filePath);
|
||||
} catch (err) {
|
||||
console.log("Error", err);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ const s3Client: S3 | undefined =
|
|||
process.env.SPACES_KEY &&
|
||||
process.env.SPACES_SECRET
|
||||
? new S3({
|
||||
forcePathStyle: false,
|
||||
forcePathStyle: !!process.env.SPACES_FORCE_PATH_STYLE,
|
||||
endpoint: process.env.SPACES_ENDPOINT,
|
||||
region: process.env.SPACES_REGION,
|
||||
credentials: {
|
||||
|
|
|
@ -13,8 +13,9 @@ declare global {
|
|||
SPACES_KEY?: string;
|
||||
SPACES_SECRET?: string;
|
||||
SPACES_ENDPOINT?: string;
|
||||
BUCKET_NAME?: string;
|
||||
SPACES_BUCKET_NAME?: string;
|
||||
SPACES_REGION?: string;
|
||||
SPACES_FORCE_PATH_STYLE?: string;
|
||||
|
||||
NEXT_PUBLIC_KEYCLOAK_ENABLED?: string;
|
||||
KEYCLOAK_ISSUER?: string;
|
||||
|
|
Ŝarĝante…
Reference in New Issue