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


Python ResourceRegistryServiceProcessClient.create_attachment方法代码示例

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


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

示例1: create_attachment

# 需要导入模块: from interface.services.coi.iresource_registry_service import ResourceRegistryServiceProcessClient [as 别名]
# 或者: from interface.services.coi.iresource_registry_service.ResourceRegistryServiceProcessClient import create_attachment [as 别名]
def create_attachment():

    try:
        payload = request.form["payload"]
        json_params = simplejson.loads(str(payload))

        ion_actor_id, expiry = get_governance_info_from_request("serviceRequest", json_params)
        ion_actor_id, expiry = validate_request(ion_actor_id, expiry)
        headers = build_message_headers(ion_actor_id, expiry)

        data_params = json_params["serviceRequest"]["params"]
        resource_id = str(data_params.get("resource_id", ""))
        fil = request.files["file"]
        content = fil.read()

        keywords = []
        keywords_str = data_params.get("keywords", "")
        if keywords_str.strip():
            keywords = [str(x.strip()) for x in keywords_str.split(",")]

        created_by = data_params.get("attachment_created_by", "unknown user")
        modified_by = data_params.get("attachment_modified_by", "unknown user")

        # build attachment
        attachment = Attachment(
            name=str(data_params["attachment_name"]),
            description=str(data_params["attachment_description"]),
            attachment_type=int(data_params["attachment_type"]),
            content_type=str(data_params["attachment_content_type"]),
            keywords=keywords,
            created_by=created_by,
            modified_by=modified_by,
            content=content,
        )

        rr_client = ResourceRegistryServiceProcessClient(node=Container.instance.node, process=service_gateway_instance)
        ret = rr_client.create_attachment(resource_id=resource_id, attachment=attachment, headers=headers)

        return gateway_json_response(ret)

    except Exception, e:
        log.exception("Error creating attachment")
        return build_error_response(e)
开发者ID:oldpatricka,项目名称:coi-services,代码行数:45,代码来源:service_gateway_service.py

示例2: create_attachment

# 需要导入模块: from interface.services.coi.iresource_registry_service import ResourceRegistryServiceProcessClient [as 别名]
# 或者: from interface.services.coi.iresource_registry_service.ResourceRegistryServiceProcessClient import create_attachment [as 别名]
def create_attachment():

    try:
        payload              = request.form['payload']
        json_params          = json_loads(str(payload))

        ion_actor_id, expiry = get_governance_info_from_request('serviceRequest', json_params)
        ion_actor_id, expiry = validate_request(ion_actor_id, expiry)
        headers              = build_message_headers(ion_actor_id, expiry)

        data_params          = json_params['serviceRequest']['params']
        resource_id          = str(data_params.get('resource_id', ''))
        fil                  = request.files['file']
        content              = fil.read()

        keywords             = []
        keywords_str         = data_params.get('keywords', '')
        if keywords_str.strip():
            keywords = [str(x.strip()) for x in keywords_str.split(',')]

        created_by           = data_params.get('attachment_created_by', 'unknown user')
        modified_by          = data_params.get('attachment_modified_by', 'unknown user')

        # build attachment
        attachment           = Attachment(name=str(data_params['attachment_name']),
                                          description=str(data_params['attachment_description']),
                                          attachment_type=int(data_params['attachment_type']),
                                          content_type=str(data_params['attachment_content_type']),
                                          keywords=keywords,
                                          created_by=created_by,
                                          modified_by=modified_by,
                                          content=content)

        rr_client = ResourceRegistryServiceProcessClient(node=Container.instance.node, process=service_gateway_instance)
        ret = rr_client.create_attachment(resource_id=resource_id, attachment=attachment, headers=headers)

        return gateway_json_response(ret)

    except Exception, e:
        log.exception("Error creating attachment")
        return build_error_response(e)
开发者ID:MatthewArrott,项目名称:coi-services,代码行数:43,代码来源:service_gateway_service.py

示例3: create_attachment

# 需要导入模块: from interface.services.coi.iresource_registry_service import ResourceRegistryServiceProcessClient [as 别名]
# 或者: from interface.services.coi.iresource_registry_service.ResourceRegistryServiceProcessClient import create_attachment [as 别名]
def create_attachment():

    try:
        resource_id        = convert_unicode(request.form.get('resource_id', ''))
        fil                = request.files['file']
        content            = fil.read()

        # build attachment
        attachment         = Attachment(name=convert_unicode(request.form['attachment_name']),
                                        description=convert_unicode(request.form['attachment_description']),
                                        attachment_type=int(request.form['attachment_type']),
                                        content_type=convert_unicode(request.form['attachment_content_type']),
                                        content=content)

        rr_client = ResourceRegistryServiceProcessClient(node=Container.instance.node, process=service_gateway_instance)
        ret = rr_client.create_attachment(resource_id=resource_id, attachment=attachment)

        ret_obj = {'attachment_id': ret}

        return json_response(ret_obj)

    except Exception, e:
        log.exception("Error creating attachment")
        return build_error_response(e)
开发者ID:swarbhanu,项目名称:coi-services,代码行数:26,代码来源:service_gateway_service.py


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