如何在Corda中下载加密的附件? [英] How to download the encrypted attachment in corda?

查看:84
本文介绍了如何在Corda中下载加密的附件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Corda中下载加密的附件?我已经在corda中上传了一个文件并对其进行了加密,并得到了哈希值.如何从其他节点下载相同的内容?

How to download the encrypted attachment in Corda? I have uploaded a file in corda and encrypted it and got the hash. How to download the same from other node?

推荐答案

考虑到,您已将Jar作为附件上传,其中包含一个文件(例如,法律协议pdf),您可以按以下方式将其提取:

Consider, you have uploaded Jar as the attachment that contains a single file (e.g. legal agreement pdf), you can extract it as below:

//Get the attachmentJar from node for attachmentHash.
val attachmentJar: InputStream = cordaRPCOps.openAttachment(attachmentHash)

//Read the content of Jar to get file name and data.
var file_name_data: Pair<String, ByteArray>? = null
JarInputStream(attachment).use { jar ->
    while (true) {
        val nje = jar.nextEntry ?: break
        if (nje.isDirectory) {
            continue
        }
        file_name_data = Pair(nje.name, jar.readBytes())
    }
}

这篇关于如何在Corda中下载加密的附件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆