You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Storage bucket.getFiles() not including sub-directories when specifying a prefix #514
GCS supports also returning "sub-directories" (i.e., common object prefixes) when listing a bucket and specifying a prefix (e.g., "/") within the query.
The sub-directories are returned as CommonPrefixes within the response.
Could these be included as well in the bucket.getFiles() response? Or maybe add a flag to specify whether subdirectories should also be returned.
Currently, the only work-around I've come up with is listing all objects within the bucket (expensive) and then filtering the response.
It might be the same thing as prefixes available through the JSON API (I'm not familiar with the XML API -- didn't even know one existed before today), in which case it's accessible through the apiResponse object provided in the 4th parameter in the getFiles() call: See here for relevant code. We're sorry it's not directly accessible through the first array of files.
Yes, I believe that is the case. You can access the CommonPrefixes value like so:
varquery={delimiter: '/'};bucket.getFiles(query,function(err,files,nextQuery,apiResponse){// files is array of files// apiResponse.prefixes is the same as CommonPrefixes});
Great to see that the common prefixes are already coming back in the fourth parameter. I think it's actually better that you keep the prefixes separated from the actual files/objects. Thanks Ryan/Stephen!
Activity
stephenplusplus commentedon Apr 29, 2015
Is this in the JSON API? https://cloud.google.com/storage/docs/json_api/v1/buckets/list doesn't seem to show it returning anything other than the objects that match the original prefix.
drewbryant commentedon Apr 29, 2015
Looks like it's in the XML API, but not the JSON API currently:
https://cloud.google.com/storage/docs/reference-headers#delimiter
ryanseys commentedon Apr 29, 2015
It might be the same thing as
prefixesavailable through the JSON API (I'm not familiar with the XML API -- didn't even know one existed before today), in which case it's accessible through the apiResponse object provided in the 4th parameter in thegetFiles()call: See here for relevant code. We're sorry it's not directly accessible through the first array of files.ryanseys commentedon Apr 30, 2015
Yes, I believe that is the case. You can access the
CommonPrefixesvalue like so:drewbryant commentedon May 1, 2015
Great to see that the common prefixes are already coming back in the fourth parameter. I think it's actually better that you keep the prefixes separated from the actual files/objects. Thanks Ryan/Stephen!
ryanseys commentedon May 1, 2015
No problem, glad we could help!
HadyZ commentedon Apr 15, 2019
Hello I tried to specify the delimiter but nothing change I cannot access a folder ref to read files from , I am using admin sdk
any help
fix(deps): google-gax v2.17.0 with mTLS (#514)
chore: release 3.15.1 (#519)
fix(deps): google-gax v2.17.0 with mTLS (#514)
chore: release 3.15.1 (#519)
fix(deps): google-gax v2.17.0 with mTLS (#514)
23 remaining items
Release v2.0.2 (#514)
Release v2.0.2 (#514)
Release v2.0.2 (#514)
test: skip failing system test (#514)
chore: release 4.1.7 (#514)
test: skip failing system test (#514)
chore: release 3.0.2 (#514)
chore(deps): update dependency gts to ^0.9.0 (#514)
chore: move CONTRIBUTING.md to root (#514)
fix(docs): move to new client docs URL (#514)
chore(deps): update dependency gts to ^0.9.0 (googleapis#514)
fix(deps): update dependency google-auth-library to v5 (#514)
fix(deps): update dependency google-auth-library to v5 (#514)
fix(deps): update dependency google-auth-library to v5 (#514)
fix(deps): update dependency google-auth-library to v5 (googleapis#514)