I tried uploading zip files using uploadAttachemnt method where I got a secureHash as output. I tried to download the same attachment using the hash as input to openAttachmnet method I got a InputStream. When I tried to read the contents of the inputStream using BuffeReader it is encrypted. I realised I had to unzip the file and read it so I got this package "import java.util.zip.ZipEntry" to read a zip file content I am unsure whether I can read the zip file contents using InputStream. How should I read the zip file contents using the InputStream? If not should I unzip and upload the file ?
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")
}