def file_put( blockchain_id, hostname, recipient_blockchain_ids, data_name, input_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
fd, output_path = tempfile.mkstemp( prefix="<STR_LIT>" )<EOL>os.fchmod( fd, <NUM_LIT> )<EOL>os.close(fd)<EOL>config_dir = os.path.dirname(config_path)<EOL>client_config_path = os.path.join(config_dir, blockstack_client.CONFIG_FILENAME )<EOL>all_recipients = []<EOL>my_hosts = file_list_hosts( blockchain_id, wallet_keys=wallet_keys, config_path=config_path )<EOL>if '<STR_LIT:error>' in my_hosts:<EOL><INDENT>log.error("<STR_LIT>" % my_hosts['<STR_LIT:error>'])<EOL>os.unlink(output_path)<EOL>return {'<STR_LIT:error>': '<STR_LIT>'}<EOL><DEDENT>if hostname in my_hosts:<EOL><INDENT>my_hosts.remove(hostname)<EOL><DEDENT>all_recipients += [(blockchain_id, host) for host in my_hosts['<STR_LIT>']]<EOL>for recipient_blockchain_id in recipient_blockchain_ids:<EOL><INDENT>their_hosts = file_list_hosts( recipient_blockchain_id, wallet_keys=wallet_keys, config_path=config_path )<EOL>if '<STR_LIT:error>' in their_hosts:<EOL><INDENT>log.error("<STR_LIT>" % (recipient_blockchain_id, their_hosts['<STR_LIT:error>']))<EOL>os.unlink(output_path)<EOL>return {'<STR_LIT:error>': '<STR_LIT>'}<EOL><DEDENT>all_recipients += [(recipient_blockchain_id, host) for host in their_hosts['<STR_LIT>']]<EOL><DEDENT>res = file_encrypt( blockchain_id, hostname, all_recipients, input_path, output_path, passphrase=passphrase, config_path=config_path, wallet_keys=wallet_keys )<EOL>if '<STR_LIT:error>' in res:<EOL><INDENT>log.error("<STR_LIT>" % res['<STR_LIT:error>'])<EOL>os.unlink(output_path)<EOL>return {'<STR_LIT:error>': '<STR_LIT>'}<EOL><DEDENT>with open(output_path, "<STR_LIT:r>") as f:<EOL><INDENT>ciphertext = f.read()<EOL><DEDENT>message = {'<STR_LIT>': ciphertext, '<STR_LIT>': res['<STR_LIT>']}<EOL>fq_data_name = file_fq_data_name( data_name ) <EOL>proxy = blockstack_client.get_default_proxy( config_path=client_config_path )<EOL>res = blockstack_client.data_put( blockstack_client.make_mutable_data_url( blockchain_id, fq_data_name, None ), message, wallet_keys=wallet_keys, proxy=proxy )<EOL>if '<STR_LIT:error>' in res:<EOL><INDENT>log.error("<STR_LIT>" % res['<STR_LIT:error>'])<EOL>os.unlink(output_path)<EOL>return {'<STR_LIT:error>': '<STR_LIT>'}<EOL><DEDENT>os.unlink(output_path)<EOL>return {'<STR_LIT:status>': True}<EOL>
Send a file to the given recipient, encrypted and signed with the
given blockchain ID.
Allow each recipient to receive the data on each of their hosts.
Return {'status': True} on success, and upload to cloud storage
Return {'error': ...} on error