mnemo_cards/mnemo_cards_backend/lib/storage/minio_config.dart

42 lines
1.3 KiB
Dart
Raw Permalink Normal View History

2025-12-19 01:52:42 +00:00
import 'dart:io';
2025-12-19 00:56:58 +00:00
/// Configuration for MinIO connection
class MinioConfig {
final String endpoint;
final int port;
final String accessKey;
final String secretKey;
final bool useSSL;
final String region;
// Bucket names
2025-12-19 04:18:46 +00:00
// Note: cardImagesBucket is used for all images (both card images and test images)
// to simplify bucket management and reduce complexity
2025-12-19 00:56:58 +00:00
static const String cardImagesBucket = 'card-images';
static const String voiceAudioBucket = 'voice-audio';
2025-12-20 10:35:54 +00:00
// Presigned URL expiration (7 days)
// Increased from 4 hours to prevent 403 errors on cached card data
2025-12-20 19:11:07 +00:00
static const int presignedUrlExpirySeconds = 1 * 24 * 60 * 60;
2025-12-19 00:56:58 +00:00
MinioConfig({
required this.endpoint,
required this.port,
required this.accessKey,
required this.secretKey,
required this.useSSL,
required this.region,
});
factory MinioConfig.fromEnvironment() {
return MinioConfig(
2025-12-19 01:52:42 +00:00
endpoint: Platform.environment['MINIO_SERVER_URL']!,
port: int.parse(Platform.environment['MINIO_PORT'] ?? '443'),
accessKey: Platform.environment['SERVICE_USER_MINIO']!,
secretKey: Platform.environment['SERVICE_PASSWORD_MINIO']!,
2025-12-19 01:59:59 +00:00
useSSL: Platform.environment['MINIO_USE_SSL'] != 'false',
2025-12-19 01:52:42 +00:00
region: Platform.environment['MINIO_REGION'] ?? 'us-east-1',
2025-12-19 00:56:58 +00:00
);
}
}