java - FTPClient.storeFile() returning false and FTP return code is 450 and says file is busy -
my requirement write file file server , connectivity or issues while writing file file server need draft mail.
while testing below code in testing environment business,client.storefile returning false few files .we placing files manually in target file server failed ones.it not expected in prod environment .any thoughts on might reason ?
fyi:business testing uploading many files.
my code:
int timeout = timeout * 1000; //variable store connection timeout abstracttrace trace = container.gettrace(); fileinputstream fis = null; ftpclient client = new ftpclient(); //creating ftpclient instance try{ ftpclientconfig conf = new ftpclientconfig(ftpclientconfig.syst_unix); conf.setdefaultdateformatstr(dateformat); client.configure(conf); try{ client.setconnecttimeout(timeout); //setting connection timeout client.connect(host);// connecting ftp server if(!client.login(username, pwd)){ throw new streamtransformationexception("authorization failed.");} //giving credentials login trace.addinfo("successfully connected server"+client.getreplystring()); if(!client.changeworkingdirectory(folderpath)){ throw new streamtransformationexception("exception occurred while changing folder path interface specific path.");} //changing current directory required folder path } catch(exception c){ throw new streamtransformationexception("exception occured while connecting server :" + c); }//close brace grab // create inputstream of file uploaded string srcfilename = filename+"_temp"+new date().gettime(); string targetfilename = filename+"_"+new date().gettime(); file sourcefile =new file(srcfilename); //if file doesn't exists, create if(!sourcefile.exists()){ sourcefile.createnewfile();} filewriter filewritter = new filewriter(sourcefile.getname(),true); bufferedwriter bufferwritter = new bufferedwriter(filewritter); bufferwritter.write(input); //writing input payload file bufferwritter.close(); fis = new fileinputstream(sourcefile); boolean done = client.storefile(targetfilename, fis); //store file server fis.close(); if (done) { trace.addinfo("!!!----file uploaded successfully----!!!"); } else { trace.addwarning("upload failed"); throw new streamtransformationexception("failed upload file :please cross check..:"); } //close brace else client.logout(); }catch(exception e){ try{ properties properties = system.getproperties(); // scheme properties properties.setproperty("mail.smtp.host",mail_host); // setup mail service server //session session = session.getdefaultinstance(properties); // default session object. session session = session.getinstance(properties); // if unknown host exception in java //sending mail service app back upwards folks mimemessage message = new mimemessage(session); // create default mimemessage object. message.setfrom(new internetaddress(mail_from)); // set from: header field of header. string recipients[] =mail_to.split(";"); internetaddress[] addressto = new internetaddress[recipients.length]; (int = 0; < recipients.length; i++) { addressto[i] = new internetaddress(recipients[i]); } message.setrecipients(message.recipienttype.to, addressto); //message.addrecipient(message.recipienttype.to,new internetaddress(mail_to)); // set to: header field of header. message.setsubject(mail_subject); // set subject: header field message.settext(e.getmessage()+"."+" failed message having field value of "+fieldname+" "+returnfieldname); // set actual message transport.send(message); // send message trace.addinfo("sent alert mail service app back upwards folks successfully"); }catch(exception mex){ trace.addwarning("failed send alert mail service : "+mex); }//close brace grab } //close brace grab { seek { if (fis != null) { fis.close(); } client.disconnect(); } grab (ioexception k) {trace.addwarning("exception while closing filestream , diconnecting"+k); } } //close brace homecoming "file placed successfully";
regards venkat
hi first seek find reply receiving method storefile()
ftp.getreplystring()
use system.out.println , find out problem ftp.
java file-upload
This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me..
ReplyDeleteBest Devops Training in pune
Best Devops Training institute in Chennai
Just stumbled across your blog and was instantly amazed with all the useful information that is on it. Great post, just what i was looking for and i am looking forward to reading your other posts soon!
ReplyDeletepython training in chennai
python course institute in chennai
A universal message I suppose, not giving up is the formula for success I think. Some things take longer than others to accomplish, so people must understand that they should have their eyes on the goal,keep it up!!!
ReplyDeleteandroid training in chennai
android online training in chennai
android training in bangalore
android training in hyderabad
android Training in coimbatore
android training
android online training
First i got a great blog .I will be interested in more similar topics. i see you got really very useful topics, i will be always checking your blog thanks.
ReplyDeletesap training in chennai
sap training in porur
azure training in chennai
azure training in porur
cyber security course in chennai
cyber security course in porur
ethical hacking course in chennai
ethical hacking course in porur
I simply wanted to thank you so much again. I am not sure the things that I might have gone through without the type of hints revealed by you regarding that situation.
ReplyDeleteweb designing training in chennai
web designing training in velachery
digital marketing training in chennai
digital marketing training in velachery
rpa training in chennai
rpa training in velachery
tally training in chennai
tally training in velachery