Project custom action was returning the name of the requested file fine a few days ago, now is not working and returning: 'Listing files error' (on the browser Network tab -> Response shows as [] Status Code: 200 ๐ I am using the version of the project at the point when everything was working fine, although wha I needed was to get a list of String names for the files I also was having trouble making that code but well, tha is another issue.
My bucket has this policy for all:
(bucket_id = 'test-tool-store'::text)
Thank you in advance to the awesome and smart coders ๐
// Automatic FlutterFlow imports
import '/backend/schema/structs/index.dart';
import '/backend/supabase/supabase.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:storage_client/src/types.dart';
Future<String> getPdfList() async {
try {
final folderName = 'pdfs';
if (folderName == null) {
throw 'Error: folder does not exist as given';
}
final searchOptions = SearchOptions(
sortBy: SortBy(column: 'name', order: 'desc'),
);
final response = await SupaFlow.client.storage
.from('test-tool-store')
.list(path: 'folderName', searchOptions: searchOptions);
if (response.isNotEmpty) {
final files = response.first;
final fileURL = files.name;
return fileURL;
} else {
return 'Listing files error';
}
} catch (error) {
return 'Error: $error';
}
}