session.write(
LocalizedFtpReply.translate(session, request, context,
FtpReply.REPLY_150_FILE_STATUS_OKAY, "STOR",
fileName)).awaitUninterruptibly(10000);
DataConnection dataConnection;
try {
dataConnection = session.getDataConnection().openConnection();
} catch (Exception e) {
LOG.debug("Exception getting the input data stream", e);
session.write(LocalizedFtpReply.translate(session, request, context,
FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "STOR",
fileName));
return;
}
// transfer data
boolean failure = false;
OutputStream outStream = null;
try {
outStream = file.createOutputStream(skipLen);
long transSz = dataConnection.transferFromClient(session.getFtpletSession(), outStream);
// attempt to close the output stream so that errors in
// closing it will return an error to the client (FTPSERVER-119)
if(outStream != null) {
outStream.close();