aves_mio1/lib/remote/remote_db_uris.dart
FabioMich66 084fa184da
Some checks failed
Quality check / Flutter analysis (push) Has been cancelled
Quality check / CodeQL analysis (java-kotlin) (push) Has been cancelled
ok con video e foto in galleria aves
2026-03-17 12:19:38 +01:00

27 lines
1.1 KiB
Dart

// lib/remote/remote_db_uris.dart
import 'dart:convert';
class RemoteDbUris {
// Schema personalizzato che non attiva ContentResolver.
static const _scheme = 'aves-remote';
/// Costruisce un URI fittizio univoco e stabile per un elemento remoto.
/// - Se hai un remoteId (hash/uuid) usa quello (preferibile).
/// - In alternativa, codifica il remotePath.
static String make({String? remoteId, String? remotePath}) {
if (remoteId != null && remoteId.trim().isNotEmpty) {
// Esempio: aves-remote://rid/<remoteId>
return '$_scheme://rid/${Uri.encodeComponent(remoteId.trim())}';
}
if (remotePath != null && remotePath.trim().isNotEmpty) {
// Esempio: aves-remote://path/<base64url(remotePath)>
final b64 = base64Url.encode(utf8.encode(remotePath.trim()));
return '$_scheme://path/$b64';
}
// Estremo fallback (pochissimo probabile)
return '$_scheme://anon/${DateTime.now().microsecondsSinceEpoch}';
}
/// Riconosce se un uri è fittizio remoto
static bool isSynthetic(String? uri) => uri != null && uri.startsWith('$_scheme://');
}