Toli, ftplet is shared for the across the whole ftp server, how can you store a reference to lastReply as a member variable in ftplet. Under concurrent usage scenario, its going to have it value overwritten by some random thread.
Thanks Sachin -----Original Message----- From: Toli Kuznets [mailto:tkuzn...@marinsoftware.com] Sent: Thursday, September 22, 2011 11:20 PM To: ftpserver-users@mina.apache.org Subject: Re: Broken uploads Nitesh, I think i'm doing what you are asking for with a combination of storing the lastReply in the afterCommand() function and then using that in the onUploadEnd() to see if the upload was successful or not. There may be a cleaner way, i'd be happy to know about that. Here's the sample code: @Override /** Override to store the last reply */ public FtpletResult afterCommand(FtpSession session, FtpRequest request, FtpReply reply) throws FtpException, IOException { lastReply = reply; return super.afterCommand(session, request, reply); } @Override public FtpletResult onUploadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException { FtpFile nativeFile = (FtpFile) session.getFileSystemView().getWorkingDirectory(); String uploadedFileName = request.getArgument(); // todo: on next Apache Ftpserver release, switch this to lastReply.isPositive() if (lastReply == null || lastReply.getCode() >= FTP_ERROR_REPLY_CODE) { SLF4JLoggerProxy.error(this, "Received an error lastReply {} for parent dir {} and file {}, there won't be real data, can't process file.", lastReply, nativeFile.getAbsolutePath(), uploadedFileName); return FtpletResult.SKIP; } doStuffOnFileUpload(nativeFile, uploadedFileName); return super.onUploadEnd(session, request); } On Thu, Sep 22, 2011 at 3:26 AM, Nitish Bangera <bangera.nit...@gmail.com> wrote: > Hello, > > Can we get a handle on broken uploads in Apache Ftpserver? By broken > uploads, what i mean is while the user's data is getting transferred to the > ftp server and he looses connection at his end, at that time i want to log > this event. Is there a way to do it in Apache Ftpserver? > > -- > Regards, > Nitish S. Bangera >