Paths/wildcards on Boto get_bucket()?

387 views
Skip to first unread message

David Cheney

unread,
Jul 21, 2011, 4:36:31 PM7/21/11
to Google Storage for Developers
Apologies if this is a FAQ.. not found an answer via search..

From within GAE, using python, I want to get a list of objects in a
GSD bucket:

uri = boto.storage_uri('mybucket','gs')
names = ''
for obj in uri.get_bucket():
names = names + " " + obj.name

This works handily but returns all items.. when what I care about is a
subset.

My objective is to get a list of images on a certain path as I would
get with a "/a/b/*.jpg"

I can obviously parse the list myself, but was hoping I'd missed magic
somewhere in the libs.

Thanks,
DJC

Mike Schwartz (Google Storage Team)

unread,
Jul 21, 2011, 4:52:35 PM7/21/11
to gs-dis...@googlegroups.com
David,

The REST API doesn't directly support wildcard request. You can ask for a prefix, but not (for example) gs://bucket/*.txt

gsutil has a library that does the wildcarding you want: please see http://code.google.com/p/gsutil/source/browse/trunk/src/gslib/wildcard_iterator.py

(Or if you just need to do some wildcarding from the command line, you can use gsutil rather than the library inside gsutil)

Mike



--
You received this message because you are subscribed to the Google Groups "Google Storage for Developers" group.
To post to this group, send email to gs-dis...@googlegroups.com.
To unsubscribe from this group, send email to gs-discussio...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gs-discussion?hl=en.


David Cheney

unread,
Jul 21, 2011, 7:17:07 PM7/21/11
to Google Storage for Developers
"a prefix" as in "gs://bucket/images/" would get me only those objects
whose names start with "images/" ?

Thanks Mike..
Dave

On Jul 21, 1:52 pm, "Mike Schwartz (Google Storage Team)" <gs-
t...@google.com> wrote:
> David,
>
> The REST API doesn't directly support wildcard request. You can ask for a
> prefix, but not (for example) gs://bucket/*.txt
>
> gsutil has a library that does the wildcarding you want: please seehttp://code.google.com/p/gsutil/source/browse/trunk/src/gslib/wildcar...
>
> (Or if you just need to do some wildcarding from the command line, you can
> use gsutil rather than the library inside gsutil)
>
> Mike
>

Mike Schwartz (Google Storage Team)

unread,
Jul 21, 2011, 7:33:46 PM7/21/11
to gs-dis...@googlegroups.com
Yes - you can see documentation for this here

Mike
Reply all
Reply to author
Forward
0 new messages