當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.calculate_sha256方法代碼示例

本文整理匯總了Python中botocore.utils.calculate_sha256方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.calculate_sha256方法的具體用法?Python utils.calculate_sha256怎麽用?Python utils.calculate_sha256使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在botocore.utils的用法示例。


在下文中一共展示了utils.calculate_sha256方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add_glacier_checksums

# 需要導入模塊: from botocore import utils [as 別名]
# 或者: from botocore.utils import calculate_sha256 [as 別名]
def add_glacier_checksums(params, **kwargs):
    """Add glacier checksums to the http request.

    This will add two headers to the http request:

        * x-amz-content-sha256
        * x-amz-sha256-tree-hash

    These values will only be added if they are not present
    in the HTTP request.

    """
    request_dict = params
    headers = request_dict['headers']
    body = request_dict['body']
    if isinstance(body, six.binary_type):
        # If the user provided a bytes type instead of a file
        # like object, we're temporarily create a BytesIO object
        # so we can use the util functions to calculate the
        # checksums which assume file like objects.  Note that
        # we're not actually changing the body in the request_dict.
        body = six.BytesIO(body)
    starting_position = body.tell()
    if 'x-amz-content-sha256' not in headers:
        headers['x-amz-content-sha256'] = utils.calculate_sha256(
            body, as_hex=True)
    body.seek(starting_position)
    if 'x-amz-sha256-tree-hash' not in headers:
        headers['x-amz-sha256-tree-hash'] = utils.calculate_tree_hash(body)
    body.seek(starting_position) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:32,代碼來源:handlers.py


注:本文中的botocore.utils.calculate_sha256方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。