Reading a zip file into a stream
I am using Cache FTP classes to download from a FTP site files, that include zip files.
I can retrieve the whole file into a stream, but it contains a lot garbage.
Sample:
PKvªZK!—XÃ×$¯²4rNDDF Plus DB/Counseling Messages/CMM 1.0/RCMMD0_DESCNUnNUCX4NDDF Plus DB/Counseling Messages/CMM 1.0/RCMMD0_DESC´½[“ÛH’.ø¾fûð²ê*›¬ï—Q[›©n]²î®Ò–ª§Ï>‚$HbØ‘)ÊâÇ÷Ï=¸P™9gmlª•„‡.~ý|4Íñ)>$Uôîòäú6K“2Jó(ù¼MªŠþ2»¢J*ócåÅ%ºÄIt*JúO²K·iž˜Ë1Σ´ŠÊd[œNI¾Kvÿ÷ÿ5&faìÛ]|Nñçh_”Ñö˜f»2ÉMg4A´KiÜ%ÙE›+Qo/Ei~-d0VQl˜s ;¢š¦)£ñ$º–˜lj>]xL|‰Ê¢8E—ätNÊøR—‰‰ŸxdI¿V4iz8^^Dþ3óþ±Hwî©«h[ä—8ÍÓüUñ)1ô’.&ùå›ê[¥..GºK7Æxcè
Is there a way to copy the zip file from the FTP site down without going through a stream?
Inside the zip file is 400+ files and directories.
That's not garbage. It's the ZIP-File itself I think. It's in binary and compressed. You need to decompress it.
I would do it like that:
s sc=$zf(-1, "sftp command here &>/dev/null; unzip cmd here &>/dev/null")
Thanks for confirming my suspicions. I have a class method that zips and unzips files. But in this case the zip file is on the FTP site and still zipped. Won't be able to unzip until I can get it down to either my local or one of our servers.
But when I down load the whole file, the unzip program doesn't recognize it as a zipped file. So I was hoping someone had a way to download or copy it from the FDP server the without reading it line by line into a Stream.
Off hand, if you are using a binary stream I would expect this to work. If it is not I would recommend contacting support investigate this in detail. It should work.
If you're using %Net.FtpSession have you checked that you're calling the Binary() method before fetching the file?