Thursday, August 28, 2014

Spring integration upload file

The framework is sometimes stupid.
For example, for Spring integration ftp upload, it rename the files after the upload is completed to avoid the partially written files.
The problem is that on our FTP server, we only have the permission to upload, no permission to rename on ftp server.
Under such case, it just cannot upload, it should have a mode to
String remoteFilePath = remoteDirectory + file.getName() + FileWritingMessageHandler.TEMPORARY_FILE_SUFFIX;
// write remote file first with .writing extension
session.write(fileInputStream, remoteFilePath);
fileInputStream.close();
// then rename it to its final name
session.rename(remoteFilePath, pathTo);

After some investigation, it's fixed after version 2.2.6 with use-temporary-file-name="false"

No comments:

Post a Comment