SFTP upload file to multiple directories on the same remote server

user1825770 :

I have implemented SFTP upload to a remote server using the example here.

My requirement is that I will have to upload the same file to multiple directories on the same server. The exact number or location of the directories will be known post-production.

Currently, my implementation allows for upload to a single directory on a single server, by setting remoteDirectoryExpression on the message handler. The remoteDirectoryExpression comes from a property file. It is expected that the remaining directories will be configured in a comma-separated way on the same property. I would like my implementation to extract each of the these comma-separated directories from the property and upload the file to each of them.

Is this even possible? I came across publish-subscribe channels but am currently struggling to understand how to include them in my implementation. Even then, pub-sub channels seem to require pre-configuring in the code where one channel = one directory. So am I even on the right track?

Gary Russell :

There is nothing built-in to do that.

The simplest way would be to create a custom splitter upstream and emit n messages with the directory in a header and then use the header value in the remote directory expression.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=148119&siteId=1