Skip to content

Commit

Permalink
Merge pull request #7 from onna/bucket-list-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
j-durbin authored Feb 15, 2023
2 parents b2dcde0 + b10b756 commit 8719fe7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
6.0.5 (unreleased)
------------------

- Configurable prefix in `iterate_bucket_page` method
[j-durbin]

6.0.4 (unreleased)
------------------

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.4
6.0.5
6 changes: 3 additions & 3 deletions guillotina_gcloudstorage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def _is_uploaded_file(file):
for_=(IResource, IRequest, IGCloudFileField), provides=IGCloudFileStorageManager
)
class GCloudFileManager(object):

file_class = GCloudFile

def __init__(self, context, request, field):
Expand Down Expand Up @@ -540,10 +539,11 @@ async def iterate_bucket(self):
yield item
page_token = data.get("nextPageToken")

async def iterate_bucket_page(self, page_token=None):
async def iterate_bucket_page(self, page_token=None, prefix=None):
url = "{}/{}/o".format(OBJECT_BASE_URL, await self.get_bucket_name())
container = task_vars.container.get()
params = {"prefix": container.id + "/"}
prefix = prefix or container.id + "/"
params = {"prefix": prefix}
if page_token:
params["pageToken"] = page_token

Expand Down

0 comments on commit 8719fe7

Please sign in to comment.