Skip to content

Support prefix filtering on listContents() for file name prefixes (not only “directory” prefixes) #1879

@lamouize-act

Description

@lamouize-act

Currently, the GoogleCloudStorageAdapter::listContents() method automatically appends a / to the provided path to build the prefix option for the underlying Bucket::objects() call:

if (! empty($prefixedPath)) { $options = ['prefix' => sprintf('%s/', rtrim($prefixedPath, '/'))]; }

This means that listContents('incoming') correctly lists objects under incoming/, but calling:
listContents('incoming/prefix_file_', false)

does not list objects whose names start with prefix_file_, because the adapter is forcing a “directory-like” behavior by appending /.

This is a limitation, because Google Cloud Storage natively supports prefix filtering for arbitrary filename prefixes, not just directory prefixes.

Why this matters
• This matches GCS’s native capabilities (prefix filtering is powerful & efficient server-side).
• It avoids listing entire buckets and filtering client-side for common patterns.
• It allows Flysystem users to use listContents() for real-world scenarios with file prefixes at scale.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions