public async Task <string> walletImportIpfs(string identifier, string jsonConfig) { WalletBackupModel model = WalletBackupModel.importFromJson(jsonConfig); IpfsFacilitator ipfs = new IpfsFacilitator(); string localPath = IOFacilitator.homePath() + "temp"; try { // get file content string txt = await ipfs.getFile(model.ipfs_path, identifier); // create local file from ipfs content IOFacilitator.createFile(txt, "temp.txt"); // convert txt to binary IOFacilitator.convertTextToByteFile("temp.txt", "temp"); // import wallet into client string res = await walletImportLocal(identifier, localPath, model.wallet_key, model.export_key); return(res); } catch (Exception e) { return($"Error: {e.Message}"); } }
static public async Task <string> backupEHR(string walletId, string ehrJson) { // encrypt ehr data CipherFacilitator cipher = new CipherFacilitator(); string encryptedEHR = cipher.encrypt(ehrJson); string relPath = walletId + "ESjson.temp"; IOFacilitator.createFile(encryptedEHR, relPath); IpfsFacilitator ipfs = new IpfsFacilitator(); string localPath = IOFacilitator.homePath() + relPath; string ipfsPath = await ipfs.addFile(localPath); ShellFacilitator.Bash("rm -f " + localPath); EHRBackupModel model = new EHRBackupModel(ipfsPath, cipher.getKey(), cipher.getIV()); model.exportToJsonFile(walletId); return(model.toJson()); }
public void exportToJsonFile() { IOFacilitator.createFile(toJson(), filePath()); }
/* * The EHR backup information is stored in a file in * filePath(identifier). This file should be deleted after it has * served its purpose. */ public void exportToJsonFile(string walletIdentifier) { IOFacilitator.createFile(toJson(), filePath(walletIdentifier)); }