Files
flux/lib/features/attachments/data/attachments_repository.dart
Mark M2 Macbook 68b075f0b1 pr?
Co-authored-by: Copilot <copilot@github.com>
2026-05-04 12:50:00 +02:00

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");
}
}
}