This commit is contained in:
Patrick Alvin Alcala 2025-02-10 17:02:37 +08:00
parent 5840df0879
commit b45cf8bd73
11 changed files with 222 additions and 34 deletions

37
lib/tables/storage.dart Normal file
View file

@ -0,0 +1,37 @@
import 'dart:developer';
import 'dart:io';
import 'package:supabase_flutter/supabase_flutter.dart';
class Storage {
final SupabaseClient _supabase = Supabase.instance.client;
Future<String> createBucket(String name) async {
try {
final response = await _supabase.storage.createBucket(name);
return response;
} catch (e, stackTrace) {
log('Error creating bucket: $e', stackTrace: stackTrace);
rethrow;
}
}
Future<List> getList() async {
try {
final response = await _supabase.storage.listBuckets();
return response;
} catch (e, stackTrace) {
log('Error getting list: $e', stackTrace: stackTrace);
rethrow;
}
}
Future<void> uploadFile(File file) async {
try {
final fileName = file.path.split('/').last;
await _supabase.storage.from('images').upload(fileName, file);
} catch (e) {
log('Error getting list: $e');
rethrow;
}
}
}