java - Strange FTPClient.storeFile behaviour -


i'm having problems uploading file ftp server.

i wrote code should connect ftp server, login, , upload file using apache commons net ftpclient:

ftpclient client = new ftpclient(); client.connect("somesite.com"); client.login("user", "password"); system.out.println("connected");  client.cwd("images/bar"); system.out.println("cwd succesful. full reply: "+client.getreplystring());  fileinputstream fis = new fileinputstream(new file(system.getproperty("user.dir")+file.separator+"current_690.jpg")); client.storefile(image_name, fis); system.out.println("succesful store. full reply: "+client.getreplystring()); 

the output terminal is:

connected cwd succesful. full reply: 250 ok. current directory /images/bar  succesful store. full reply: 226-file transferred 226 3.190 seconds (measured here), 9.99 kbytes per second 

the problem if go user.dir , open current_690.jpg displays me image correctly, if download image uploaded ftpclient, when open it, os says unable preview image, probabily it's corrupted or it's big.

in fact noticed on pc image size 32708 bytes, on server shows me 32615 bytes, think last part of image not being uploaded.

why? missing something?

the default file type ascii need tell tranfer binary, setting client.setfiletype(ftpclient.binary_file_type); before storefile call.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -