def create_attachment(): try: resource_id = str(request.form.get('resource_id', '')) fil = request.files['file'] content = fil.read() # build attachment attachment = Attachment( name=str(request.form['attachment_name']), description=str(request.form['attachment_description']), attachment_type=int(request.form['attachment_type']), content_type=str(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)
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)
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)
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)
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)