python 2.7 - boto - What exactly is a key? -


as title says, key in boto?

  • what encapsulate (fields, data structures, methods etc.)?
  • how 1 access file contents files in aws bucket using key/boto?

i not able find information on official documentation or on other third party website. provide info?

here examples of usage of key object:

def download_file(key_name, storage):     key = bucket.get_key(key_name)     try:         storage.append(key.get_contents_as_string())     except:         print "some error message." 

and:

for key in keys_to_process:     pool.spawn_n(download_file, key.key, file_contents) pool.waitall() 

in code example - key object reference unique identifier within bucket.

think of buckets table in database think of keys rows in table reference key (better known object) in bucket.

often in boto (not boto3) works this

from boto.s3.connection import s3connection connection = s3connection()  # assumes have .boto or boto.cfg setup bucket = connection.get_bucket('my_bucket_name_here') # table name in sql, select object form tablename key = bucket.get_key('my_key_name_here') object in above sql example.  key names string, , there convention says if put '/' in name, viewer/tool should treat path/folder user, e.g.  my/object_name/is_this key inside bucket, viewers show folder, , object_name folder, , looks file called is_this ui convention 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -