List file properties
You can list files without having to download all the files. You can do this by using the list
API from the Amplify Library for Storage.
List Files
StoragePagedListOptions options = StoragePagedListOptions.builder() .setPageSize(1000) .build();
Amplify.Storage.list( StoragePath.fromString("public/"), options, result -> { for (StorageItem item : result.getItems()) { Log.i("MyAmplifyApp", "Item: " + item.getPath()); } Log.i("MyAmplifyApp", "Next Token: " + result.getNextToken()); }, error -> Log.e("MyAmplifyApp", "List failure", error););
val options = StoragePagedListOptions.builder() .setPageSize(1000) .build()
Amplify.Storage.list(StoragePath.fromString("public/"), options, { result -> result.items.forEach { item -> Log.i("MyAmplifyApp", "Item: ${item.path}") } Log.i("MyAmplifyApp", "Next Token: ${result.nextToken}") }, { Log.e("MyAmplifyApp", "List failure", it) })
val options = StoragePagedListOptions.builder() .setPageSize(1000) .build()
try { val result = Amplify.Storage.list(StoragePath.fromString("public/"), options) result.items.forEach { Log.i("MyAmplifyApp", "Item: $it") } Log.i("MyAmplifyApp", "next token: ${result.nextToken}")} catch (error: StorageException) { Log.e("MyAmplifyApp", "List failure", error)}
StoragePagedListOptions options = StoragePagedListOptions.builder() .setPageSize(1000) .build();
RxAmplify.Storage.list(StoragePath.fromString("public/"), options) .subscribe( result -> { for (StorageItem item : result.getItems()) { Log.i("MyAmplifyApp", "Item: " + item.getPath()); } Log.i("MyAmplifyApp", "Next Token: " + result.getNextToken()); }, error -> Log.e("MyAmplifyApp", "List failure", error); );