apache - 550 Error on Uploading Files using FTP over SSL Android -
i'm using apache
commonsnet
library ftp
. i'm able create folders in ftp server. whenever storefile
it's failing , returning me 550 error.
ftpupload
private boolean ftpupload(string remotefilepath) { ftpsclient ftpsclient = null; try { ftpsclient = new ftpsclient("ssl", true); } catch (nosuchalgorithmexception e) { e.printstacktrace(); } fileinputstream fis; boolean result = false; try { if (ftpsclient != null) { ftpsclient.setconnecttimeout(10000); keymanagerfactory kmf = keymanagerfactory.getinstance(keymanagerfactory.getdefaultalgorithm()); kmf.init(null, null); keymanager km = kmf.getkeymanagers()[0]; ftpsclient.setkeymanager(km); ftpsclient.connect(inetaddress.getbyname(getstring(r.string.ftp_hostname)), 990); boolean isloggedin = ftpsclient.login(getstring(r.string.ftp_username), getstring(r.string.ftp_password)); if (isloggedin) { // on successful login ftpsclient.setfiletype(ftp.binary_file_type); ftpsclient.enterlocalpassivemode(); ftpsclient.setbuffersize(1000); // check remotepath exists else create folders int index = remotefilepath.lastindexof("/"); string remotedir = null; if (index != -1) remotedir = remotefilepath.substring(0, index); if (remotedir != null) /** * changeworkingdirectory returns whether specified directory exist or not. * if not exist in remote, create folders */ if (!ftpsclient.changeworkingdirectory(remotedir)) { if (makedirectories(ftpsclient, remotedir)) ftpsclient.changeworkingdirectory(remotefilepath); else log.e(this.getclass().getsimplename(), "remote path not available"); } else ftpsclient.changeworkingdirectory(remotefilepath); //testing file localfilepath = new file(environment.getexternalstoragedirectory() + "/qwerty.png"); ftpsclient.addprotocolcommandlistener(new printcommandlistener(new printwriter(system.out))); try{ int reply = ftpsclient.getreplycode(); if (!ftpreply.ispositivecompletion(reply)) { ftpsclient.disconnect(); log.e(this.getclass().getsimplename(), "connection refused server"); return false; } } catch(exception e) { e.printstacktrace(); } // stream of file string testname = localfilepath.getname(); fis = new fileinputstream(localfilepath); // upload file ftp server result = ftpsclient.storefile(testname, fis); fis.close(); log.i(this.getclass().getsimplename(), "ftp store result " + result); if (result) { result = true; } else { result = false; } } else { log.e(this.getclass().getsimplename(), "login fail!"); result = false; } // logout ftp server ftpsclient.logout(); } } catch (exception e) { log.e(this.getclass().getsimplename(), "ftp exception!"); result = false; } return result; }
it's connecting, authenticating, created new folder storingfile
/getreplycode
returns 550. wrong here? have removed keymanagerfactory
no luck.
Comments
Post a Comment