Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated May 16, 2024

List file properties

You can list files without having to download all the files. You can do this by using the listFile API from the Amplify Library for Storage. You can also get properties individually for a file using the getProperties API.

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);
);