23
lib/features/attachments/data/attachments_repository.dart
Normal file
23
lib/features/attachments/data/attachments_repository.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
class AttachmentsRepository {
|
||||
final _supabase = Supabase.instance.client;
|
||||
|
||||
/// Scarica i byte di un file direttamente da Supabase Storage
|
||||
Future<Uint8List> downloadAttachmentBytes(String storagePath) async {
|
||||
try {
|
||||
// ATTENZIONE: Sostituisci 'attachments' con il nome VERO del tuo bucket su Supabase!
|
||||
// Se il tuo storagePath contiene già il nome del bucket all'inizio,
|
||||
// assicurati di passargli solo il percorso interno.
|
||||
final Uint8List bytes = await _supabase.storage
|
||||
.from('attachments') // <--- NOME DEL TUO BUCKET
|
||||
.download(storagePath);
|
||||
|
||||
return bytes;
|
||||
} catch (e) {
|
||||
throw Exception("Impossibile scaricare il documento dal cloud: $e");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user