Empty file after upload with JAVA on my ftp server

一笑奈何 提交于 2019-12-06 14:48:21
Vamsi Mohan Jayanti

I think it could be something to do with the mode of file transfer . Can you set the trandfer mode to Binary. Some times when you sent data in ASCII it goes corrupted . Refer to this https://superuser.com/questions/82726/how-to-set-binary-mode-by-default-when-ftping-to-a-remote-site

It tells how to set binary mode in FTP Command client. You will have a similar provision in FTPClient class also.

Just found I think similar question is answered here FTPClient - Java, upload file

It seems like the problem has to do with the implementation of the FTPClient. Are you sure that the class works like that?

Try uploading to a different server or using a different class to find the reason for the failure.

Also: Are you sure that it is your responsibility to close the FileInputStream? I could imagine that the .storeFile(…) method will close it itself, when it is done.

Add these lines before client.login ftpClient default protocol is full text only for other files you nead to specifie binnary mode

client.enterLocalPassiveMode()
client.setFileType(FTP.BINARY_FILE_TYPE, FTP.BINARY_FILE_TYPE);
client.setFileTransferMode(FTP.BINARY_FILE_TYPE);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!