python - In Amazon S3 am I charged whenever I perform a get_key or when I actually get its contents? -



python - In Amazon S3 am I charged whenever I perform a get_key or when I actually get its contents? -

i.e. code cause appear 2 requests in bill, or 1?

key = bucket.get_key('some_invalid_key') key = bucket.get_key('some_valid_key') string = key.get_contents_to_string()

by default, get_key validate existence of key on bucket head request (which rather little one, request counts number of requests do).

if not want create validation, set validate=false , boto not create request.

docstring get_key:

type: instancemethod string form: <bound method bucket.get_key of <bucket: tmpdistributionplatform>> file: /home/javl/envs/so/local/lib/python2.7/site-packages/boto/s3/bucket.py definition: bucket.get_key(self, key_name, headers=none, version_id=none, response_headers=none, validate=true) docstring: check see if particular key exists within bucket. method uses head request check existance of key. returns: instance of key object or none :param key_name: name of key retrieve :type key_name: string :param headers: headers send when retrieving key :type headers: dict :param version_id: :type version_id: string :param response_headers: dictionary containing http headers/values override headers associated stored object in response. see http://goo.gl/ewopb details. :type response_headers: dict :param validate: verifies whether key exists. if ``false``, not nail service, constructing in-memory object. default ``true``. :type validate: bool :rtype: :class:`boto.s3.key.key` :returns: key object bucket. conclusions by default get_key generates 1 head requests , charged it. you allowed prevent request setting validate=false amount of info transferred anyway little head checks basic metadata , not effort download content. head request falls category , others , cost $0.004 per 10,000 requests (as of standard zone), negligible unless lot of these requests. to question: your code generate 2 head , 1 requests , 3 counted.

python amazon-web-services amazon-s3 amazon

Comments