I am trying to list all the files in my bucket via:
Amplify.Storage.list("",
result -> {
for (StorageItem item : result.getItems()) {
Log.i("MyAmplifyApp", "File: " + item.getKey() + ", Hash: " + item.getETag());
}
},
error -> Log.e("MyAmplifyApp", "List failure", error)
);
But I am only interested in files, not directories. How do I do that?
I was not able to find a definite solution to my problem. Here is the closest solution I wrote:
Amplify.Storage.list("",
result -> {
for (StorageItem item : result.getItems()) {
if(item.getSize() == 0) {
Log.i(TAG, "File is empty, skip: " + item.getKey());
continue;
}
Log.i("MyAmplifyApp", "File: " + item.getKey() + ", Hash: " + item.getETag());
}
}
error -> Log.e("MyAmplifyApp", "List failure", error)
);
This simply ignores any StorageItem
that is zero bytes in size. This works in my case because aside from directories, I am also not interested in empty files.