fetchStorageList function
Implementation
Future<Storage?> fetchStorageList(String url, String anonKey) async {
if (!url.startsWith("http://") && !url.startsWith("https://")) {
url = "https://$url"; // Default to HTTPS if no scheme is provided
}
try {
// First attempt with API key
final response = await _secureRequest('$url/storage/v1/bucket/', anonKey);
if (response.statusCode == 200) {
return Storage.fromJson(jsonDecode(response.body));
}
print(
"Failed to fetch Supabase storage information. Status code: ${response.statusCode}");
print("Response body: ${response.body}");
} catch (e) {
print("Error fetching Supabase storage information: $e");
}
return null;
}