python - How to get the right s3 keys? -


i have s3 bucket thousands of keys in tested directories: iterating through each key with:

for key in bucket.list():   print key.name 

yields output like:

"/dir2/dir2/banana/dir4/file1" "/dir1/dir2/apple/dir4/file2"

the problem when iterate this, slow if want list of keys have "/dir1/dir2/apple". also, if there no keys match criteria slow appears iterate on keys.

what correct way listing of keys within buckets want?

look delimiter , prefix parameters in docs

for files in bucket.get_all_keys(delimiter = '/', prefix = '/dir1/dir2/'):     print files 

while delimiter / , prefix can set depending on location want read files from


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -