diff --git a/lib/features/attachments/data/attachments_repository.dart b/lib/features/attachments/data/attachments_repository.dart index 9b86fdf..037db97 100644 --- a/lib/features/attachments/data/attachments_repository.dart +++ b/lib/features/attachments/data/attachments_repository.dart @@ -59,6 +59,12 @@ class AttachmentsRepository { required String companyId, }) async { try { + if (pickedFile.bytes == null) { + throw Exception( + "I bytes del file sono vuoti! Ricarica la pagina senza cache.", + ); + } + final extension = pickedFile.extension ?? pickedFile.name.split('.').last; final cleanName = pickedFile.name .replaceAll(RegExp(r'[^\w\s\.-]'), '') @@ -97,7 +103,7 @@ class AttachmentsRepository { // 3. Salviamo su Postgres await _supabase.from(_tableName).insert(insertData); } catch (e) { - throw Exception("Errore nel caricamento del file: $e"); + throw Exception("Errore caricamento: $e"); } }