java - Zip file corrupted (sort of) after SFTP transfer/put (Jsch) -


I use this code to send the code via SFTP:

  private Sending zero (string sftpHost, int sftpPort, string user, string sshPrivateKeyPath, string sshPassphrase, string sftpDir, string filename) {session session = faucet; Channel channel = null; ChannelSftp Channel SFTP = Faucet; FileInputStream fis = null; Try {JSch jsch = new JSch (); Jsch.addIdentity (sshPrivateKeyPath, sshPassphrase); Java.util.Properties config = new java.util.Properties (); Config.put ("hardhostky checking", "no"); Session.setConfig (config); Session.connect (); Channel = session. Open channel ("SFTP"); Channel.connect (); ChannelSftp = (ChannelSftp) channel; ChannelSftp.cd (sftpDir); File f = new file (filename); Fis = new FileInputStream (f); ChannelSftp.put (fis, f.getName (), ChannelSftp.OVERWRITE); } Hold (exception before) {logger.error ("send file failed", prior); Throw new runtime up (ex); } Finally {try {if (fis! = Null) fis.close (); } Hold (IOException e) {logger.error ("error in closing stream", e); } If (channelSftp! = Null) channelSftp.exit (); If (channel! = Null) channel.disconnect (); If (session! = Zero) session.disconnect (); Both machines work with the unzip on both machines / santos 6.5 VMS, Java 1.7.0_51, OpenJDK, Tomcat 7.0.50  

Source / Client Server - On Jade Destination / Server, I get this error:

  Archive: filename.zip [filename.zip] The signature of the middle-mid-directory was not found. Either this file is not a zipfile, or it is a disk of multi-part archive. In the latter case, central directory and zipfile comments will be found on the last disc (disc) of this archive. Zipinfo: can not find the zipfile directory in any one of filename.zip or filename.zip.zip, and can not find filename.zip.ZIP, period.   

The size of the file also changes:

Source (OK)

  - R-R-R ... 1 Root Route 49170 10 Oct 15:35 filename.zip   

Prevention (corrupt)

  -r-R-R-R--. 1 user user 45710 10th October 15:35 filename.zip   

I also tried jar -tf running corrupt files and found:

  Java.util .zip.ZipException: Error opening zip file   

But when I tried Jar XVF, it successfully removed files, it is not completely "corrupt" / P>

I also tried to transfer my Windows 7 machine through WinSCP and tried 7zip, but It also can not open the file

I was probably thinking that JSC has a setting of binary files but I have not got any.

Thanks for any help / direction which you can give

Update 1: I have also tried the same with the SCP interface of Jessch.

2 Update: I have tried sshj sftp with the same result, so there is not a jsc problem ...

3 updates: I have also tried to add the code given below. Although the file size has changed, it will still not be open-z

  config.put ("compression.s2c", "none"); Config.put ("compression.c2s", "none"); Config.put ("compression_level", "0");    

All this is due to my stupidity used to create zip used by this code The zippedstream was not closed yet, i.e. the same attempt was made to send zip creation and file - the catch-end block Sorry to waste time at somebody's time.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -