当前位置: 首页>>代码示例>>Python>>正文


Python Request.headers[GLACIER_FLAG_META]方法代码示例

本文整理汇总了Python中swift.common.swob.Request.headers[GLACIER_FLAG_META]方法的典型用法代码示例。如果您正苦于以下问题:Python Request.headers[GLACIER_FLAG_META]方法的具体用法?Python Request.headers[GLACIER_FLAG_META]怎么用?Python Request.headers[GLACIER_FLAG_META]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在swift.common.swob.Request的用法示例。


在下文中一共展示了Request.headers[GLACIER_FLAG_META]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: transition

# 需要导入模块: from swift.common.swob import Request [as 别名]
# 或者: from swift.common.swob.Request import headers[GLACIER_FLAG_META] [as 别名]
    def transition(self, env):
        # GET Object body
        req = Request(copy(env))
        req.method = 'GET'
        resp = req.get_response(self.app)

        obj_body = resp.body

        # Glacier로 업로드
        tmpfile = self.save_to_tempfile(obj_body)
        try:
            glacier = self._init_glacier()
            archive_id = glacier.upload_archive(tmpfile)
            glacier_obj = make_glacier_hidden_object_name(self.obj, archive_id)
        except Exception as e:
            return Response(status=HTTP_INTERNAL_SERVER_ERROR, body=e.message)
        finally:
            self.delete_tempfile(tmpfile)

        # Object를 0KB로 만들기
        req = Request(copy(env))
        req.headers[GLACIER_FLAG_META] = True
        resp = req.get_response(self.app)

        # Glacier Hidden account에 기록
        glacier_account = self.glacier_account_prefix + self.account
        part, nodes = self.container_ring.get_nodes(glacier_account,
                                                    self.container)
        hidden_path = '/%s/%s/%s' % (glacier_account, self.container,
                                     glacier_obj)
        for node in nodes:
            ip = node['ip']
            port = node['port']
            dev = node['device']
            headers = dict()
            headers['user-agent'] = 'transition-middleware'
            headers['X-Timestamp'] = normalize_timestamp(time.time())
            headers['referer'] = req.as_referer()
            headers['x-size'] = '0'
            headers['x-content-type'] = 'text/plain'
            headers['x-etag'] = 'd41d8cd98f00b204e9800998ecf8427e'

            conn = http_connect(ip, port, dev, part, 'PUT', hidden_path,
                                headers)
            conn.getresponse().read()
        return Response(status=HTTP_NO_CONTENT)
开发者ID:KoreaCloudObjectStorage,项目名称:swift-lifecycle-management,代码行数:48,代码来源:middleware.py


注:本文中的swift.common.swob.Request.headers[GLACIER_FLAG_META]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。