english version and minio console access

This commit is contained in:
Georgiy Syralev
2025-12-13 12:53:28 +03:00
parent 753696cc93
commit b799f278a4
47 changed files with 4386 additions and 1264 deletions

View File

@@ -30,6 +30,18 @@ export function buildPhysicalBucketName(userId: number, logicalName: string): st
return `${prefix}-${userId}-${logicalName}`.toLowerCase();
}
export function isMinioAuthError(err: unknown): boolean {
if (!err || typeof err !== 'object') return false;
const message = (err instanceof Error ? err.message : String(err)).toLowerCase();
return message.includes('invalidaccesskeyid') || message.includes('accesskeyid') || message.includes('invalid access key') || message.includes('signaturedoesnotmatch') || message.includes('signature does not match');
}
export function isMinioNoSuchBucketError(err: unknown): boolean {
if (!err || typeof err !== 'object') return false;
const message = (err instanceof Error ? err.message : String(err)).toLowerCase();
return message.includes('nosuchbucket') || message.includes('notfound') || message.includes('no such bucket');
}
export async function ensureBucketExists(bucketName: string, region: string): Promise<void> {
try {
const exists = await minioClient.bucketExists(bucketName);
@@ -37,6 +49,17 @@ export async function ensureBucketExists(bucketName: string, region: string): Pr
await minioClient.makeBucket(bucketName, region);
}
} catch (err: unknown) {
if (isMinioAuthError(err)) {
// Provide a more actionable error message for auth issues
const e = new Error(`MinIO authentication failed for endpoint ${MINIO_ENDPOINT}:${MINIO_PORT}. Check MINIO_ACCESS_KEY/MINIO_SECRET_KEY environment variables.`);
(e as any).code = 'MINIO_AUTH_ERROR';
throw e;
}
if (isMinioNoSuchBucketError(err)) {
const e = new Error(`MinIO bucket error: bucket ${bucketName} not found or inaccessible.`);
(e as any).code = 'MINIO_BUCKET_NOT_FOUND';
throw e;
}
throw err;
}
}