This commit is contained in:
alma 2025-05-04 13:57:14 +02:00
parent dab73b433c
commit 4124c4d2bb
3 changed files with 12 additions and 9 deletions

View File

@ -16,7 +16,7 @@ export async function POST(request: Request) {
// Forward to storage handler
try {
const { POST: storageInitHandler } = await import('@/app/api/storage/init/route');
return await storageInitHandler();
return await storageInitHandler(request);
} catch (error) {
console.error('Error calling storage init handler:', error);
return NextResponse.json({ error: 'Failed to initialize storage' }, { status: 500 });

View File

@ -4,6 +4,9 @@ import { authOptions } from '@/app/api/auth/[...nextauth]/route';
import { S3Client, ListBucketsCommand } from '@aws-sdk/client-s3';
import { createUserFolderStructure, listUserObjects } from '@/lib/s3';
// Import the configured S3 client from lib/s3.ts
import { s3Client as configuredS3Client } from '@/lib/s3';
// Cache for folder lists
const folderCache = new Map<string, { folders: string[], timestamp: number }>();
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
@ -26,16 +29,10 @@ export async function GET() {
});
}
// Check S3 connectivity
const s3Client = new S3Client({
region: process.env.MINIO_AWS_REGION || 'eu-east-1',
endpoint: process.env.MINIO_S3_UPLOAD_BUCKET_URL || 'https://dome-api.slm-lab.net/',
forcePathStyle: true
});
// Check S3 connectivity using the configured client
try {
// Simple check by listing buckets
await s3Client.send(new ListBucketsCommand({}));
await configuredS3Client.send(new ListBucketsCommand({}));
} catch (error) {
console.error('S3 connectivity check failed:', error);
return NextResponse.json({

View File

@ -11,6 +11,12 @@ export const s3Client = new S3Client({
region: S3_REGION,
endpoint: S3_BUCKET_URL,
forcePathStyle: true, // Required for MinIO
credentials: {
// Use anonymous credentials as MinIO is configured with Keycloak
// and we're using the policy you provided
accessKeyId: 'anonymous',
secretAccessKey: 'anonymous'
}
});
// Helper functions for S3 operations