Skip to content

Instantly share code, notes, and snippets.

@adamcyber1
Created September 22, 2020 00:21
Show Gist options
  • Save adamcyber1/c96d4d335a4c4a0737780cccbe19dc7e to your computer and use it in GitHub Desktop.
Save adamcyber1/c96d4d335a4c4a0737780cccbe19dc7e to your computer and use it in GitHub Desktop.
Doogle Grive List File
Future<List<StorageItem>> listFiles() async {
try {
ListResult res = await Amplify.Storage.list();
AuthUser user = await Amplify.Auth.getCurrentUser();
List<StorageItem> items = res.items
.where((e) => e.key.split('/').first.contains(user.username))
.toList();
return items;
} catch (e) {
Alert(
context: context,
type: AlertType.error,
desc: "Error Listing Files: " + e.toString()).show();
// return an empty list if something fails
return List<StorageItem>(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment