【发布时间】:2018-11-19 23:50:36
【问题描述】:
我尝试使用 uploadAttachemnt 方法上传 zip 文件,其中我得到了一个 secureHash 作为输出。 我尝试使用哈希作为 openAttachmnet 方法的输入来下载相同的附件,我得到了一个 InputStream。 当我尝试使用 BuffeReader 读取 inputStream 的内容时,它被加密了。我意识到我必须解压缩文件并阅读它,所以我得到了这个包“import java.util.zip.ZipEntry”来读取 zip 文件的内容 我不确定是否可以使用 InputStream 读取 zip 文件内容。 我应该如何使用 InputStream 读取 zip 文件的内容?如果不是,我应该解压缩并上传文件吗?
fun main(args: Array<String>) :String {
require(args.isNotEmpty()) { "Usage: uploadBlacklist <node address>" }
args.forEach { arg ->
val nodeAddress = parse(args[0])
val rpcConnection = CordaRPCClient(nodeAddress).start("user1", "test")
val proxy = rpcConnection.proxy
val attachmentInputStream = File(args[1]).inputStream()
val attachmentHash = proxy.uploadAttachment(attachmentInputStream)
print("AtachmentHash"+attachmentHash)
// Download the attachment
val inputString = proxy.openAttachment(attachmentHash).bufferedReader().use { it.readText() }
println("The contents are ")
print(inputString)
val file = File("OutputFile.txt")
file.writeText(inputString)
rpcConnection.notifyServerAndClose()
}
return("File downloaded successfully in the path")
}
【问题讨论】:
标签: blockchain corda