24 lines
809 B
Dart
24 lines
809 B
Dart
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");
|
|
}
|
|
}
|
|
}
|