Zip File attachment

(Kiara) #1

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” 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 ?
I also tried to read the contents using JarInputStream but the contents are empty. please help

        val attachmentInputStream = File(args[1]).inputStream()
        val attachmentHash = proxy.uploadAttachment(attachmentInputStream)

        val attachmentDownloadInputStream = proxy.openAttachment(attachmentHash)
        val attachmentJar = JarInputStream(attachmentDownloadInputStream)

        val contents = attachmentJar.bufferedReader().readLines()
        println("The contents are $contents")


Output : `I 15:21:08 1 RPCClient.logElapsedTime - Startup took 35 msec
AtachmentHash709FF97D2CAE131B0B8503DF49B897412DE736AAB9519D3D0BDC473559960B70The contents are []

Process finished with exit code 0`