本文整理汇总了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)
示例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)
示例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)