Amplify.Storage: 有没有办法只列出我存储桶中的文件?

Amplify.Storage: Is there a way to list only the files in my bucket?

我正在尝试通过以下方式列出存储桶中的所有文件:

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

但我只对文件感兴趣,对目录不感兴趣。我该怎么做?

我无法找到解决问题的确切方法。这是我写的最接近的解决方案:

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

这会忽略任何大小为零字节的 StorageItem。这适用于我的情况,因为除了目录之外,我对空文件也不感兴趣。