google-cloud-storagegcloud-java

gcloud-java-storage Storage.BlobListOption.recursive(false) not working


I am trying to do an non-recursive list using gcloud-java storage on GCS bucket outside appengine based on this suggestion

However it seems that its not working as expected, namely it is still listing all the files although I have set the Storage.BlobListOption.recursive(false)

my code structure is basically like: Storage client = StorageOptions.defaultInstance().service(); Page<Blob> blobPage = client.list(my_bucket, Storage.BlobListOption.recursive(false)); for (Blob blob : blobPage.values()) { // it is still iterating all the leaf files in my_bucket }

Actually later on I found that it seems that none of BlobListOption seems to be taking affect (maxResults, prefix) and list will just return all leaf files no matter what...

Am I using the API wrong or what might be the problem?


Solution

  • There was a bug with non-recusrive blob and prefix (folder) listing. This was fixed in since v 0.1.15 (see this). The recursive option was replaced with currentDirectory and now you can get the prefixes/child folders. If this does not work for you or you think any of the other options does not work as intended please file an issue and it will be taken care of quickly.