diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java index 43a29d10e43ef..8c827aa5ef4a1 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java @@ -710,6 +710,14 @@ public boolean storeFile(String name, Exchange exchange, long size) throws Gener clientActivityListener.onUploadComplete(endpoint.getConfiguration().remoteServerInformation(), name); } + if (!answer) { + Integer code = exchange.getIn().getHeader(FtpConstants.FTP_REPLY_CODE, Integer.class); + String status = exchange.getIn().getHeader(FtpConstants.FTP_REPLY_STRING, String.class); + if (code != null && status != null) { + throw new GenericFileOperationFailedException(code, status, "Error writing file [" + targetName + "]"); + } + } + return answer; }