admin
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
This commit is contained in:
parent
6d499dc584
commit
ead08e7337
3 changed files with 34 additions and 8 deletions
|
|
@ -674,11 +674,24 @@ class AdminCardsApiV2 {
|
||||||
return _json(SuccessResponse(success: true).toJson());
|
return _json(SuccessResponse(success: true).toJson());
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
print('Error in updateCard: $e\n$s');
|
print('Error in updateCard: $e\n$s');
|
||||||
|
|
||||||
|
// Check for common database errors
|
||||||
|
final errorMessage = e.toString().toLowerCase();
|
||||||
|
String details = 'An unexpected error occurred while updating the card.';
|
||||||
|
|
||||||
|
if (errorMessage.contains('constraint') || errorMessage.contains('unique')) {
|
||||||
|
details = 'A card with similar data may already exist. Please check for duplicates.';
|
||||||
|
} else if (errorMessage.contains('foreign key') || errorMessage.contains('pack')) {
|
||||||
|
details = 'The specified pack ID may be invalid. Please verify that the pack exists.';
|
||||||
|
} else if (errorMessage.contains('null') || errorMessage.contains('required')) {
|
||||||
|
details = 'Required fields are missing or invalid. Please check all required fields are provided.';
|
||||||
|
}
|
||||||
|
|
||||||
return _json(
|
return _json(
|
||||||
ErrorResponse(
|
ErrorResponse(
|
||||||
error: 'Internal server error',
|
error: 'Internal server error',
|
||||||
message: 'Failed to update card',
|
message: 'Failed to update card',
|
||||||
details: 'An unexpected error occurred while updating the card. Please try again later.',
|
details: details,
|
||||||
).toJson(),
|
).toJson(),
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -156,12 +156,18 @@ class PacksApiV2 {
|
||||||
if (!_isValidUuid(value)) return null;
|
if (!_isValidUuid(value)) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await _minioService.getPresignedUrl(
|
final url = await _minioService.getPresignedUrl(
|
||||||
bucket: bucket,
|
bucket: bucket,
|
||||||
objectId: value,
|
objectId: value,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
if (url == null) {
|
||||||
print('Error generating presigned URL for $bucket/$value: $e');
|
print('⚠️ Warning: Failed to generate presigned URL for $bucket/$value - object may not exist in MinIO');
|
||||||
|
} else {
|
||||||
|
print('✅ Generated presigned URL for $bucket/$value (expires in ${MinioConfig.presignedUrlExpirySeconds}s)');
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
} catch (e, s) {
|
||||||
|
print('❌ Error generating presigned URL for $bucket/$value: $e\n$s');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ class MinioService {
|
||||||
///
|
///
|
||||||
/// [bucket] - The bucket name
|
/// [bucket] - The bucket name
|
||||||
/// [objectId] - The object ID (UUID)
|
/// [objectId] - The object ID (UUID)
|
||||||
/// [expirySeconds] - Optional expiry time in seconds (default: 4 hours)
|
/// [expirySeconds] - Optional expiry time in seconds (default: 7 days)
|
||||||
///
|
///
|
||||||
/// Returns the presigned URL, or null if the object doesn't exist
|
/// Returns the presigned URL, or null if the object doesn't exist
|
||||||
Future<String?> getPresignedUrl({
|
Future<String?> getPresignedUrl({
|
||||||
|
|
@ -101,6 +101,7 @@ class MinioService {
|
||||||
required String objectId,
|
required String objectId,
|
||||||
int? expirySeconds,
|
int? expirySeconds,
|
||||||
}) async {
|
}) async {
|
||||||
|
final expiry = expirySeconds ?? MinioConfig.presignedUrlExpirySeconds;
|
||||||
try {
|
try {
|
||||||
// Check if object exists
|
// Check if object exists
|
||||||
await _client.statObject(bucket, objectId);
|
await _client.statObject(bucket, objectId);
|
||||||
|
|
@ -109,13 +110,19 @@ class MinioService {
|
||||||
final url = await _client.presignedGetObject(
|
final url = await _client.presignedGetObject(
|
||||||
bucket,
|
bucket,
|
||||||
objectId,
|
objectId,
|
||||||
expires: expirySeconds ?? MinioConfig.presignedUrlExpirySeconds,
|
expires: expiry,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
print('✅ Generated presigned URL for $bucket/$objectId (expires in ${expiry}s)');
|
||||||
return url;
|
return url;
|
||||||
} catch (e) {
|
} on MinioException catch (e) {
|
||||||
print(
|
print(
|
||||||
'⚠️ Warning: Failed to generate presigned URL for $bucket/$objectId: $e',
|
'❌ MinIO error generating presigned URL for $bucket/$objectId: ${e.code} - ${e.message}',
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
} catch (e, s) {
|
||||||
|
print(
|
||||||
|
'❌ Unexpected error generating presigned URL for $bucket/$objectId: $e\n$s',
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue