Description
Spring integration version used: 6.2.1 (also tested on 6.2.5)
When configuring a SMB outbound gateway through XML configuration with a 'get' command, and point the 'expression' field to the name of the file I with to retrieve, I receive an IOException: [path] is not a directory. Cannot list resources
Upon some further investigation, it appears that AbstractRemoteFileOutboundGateway#get, that is invoked for get commands will execute a list action against the (Smb)Session. The list action is supposed to return a single file. If so, it is copied to the local directory, otherwise an error is thrown. In contrast with the SftpSession#list, the SmbSession#list will always throw an example if a list is attempted on a non-directory SMB file.
It seems that the SmbSession should also have logic in place that will list the directory instead, and filter files based on the path provided, just like the SftpSession has? When using SFTP instead of SMB, a similar setup as presented below works.
To Reproduce
Configure a SMB share that hosts a simple 'smbtest.txt' file in the 'test' folder.
Run the XML below (with the proper directory) and see that.
<int:inbound-channel-adapter channel="trigger" expression="'trigger'">
<int:poller fixed-delay="10" time-unit="SECONDS"/>
</int:inbound-channel-adapter>
<int:channel id="trigger"/>
<smb:outbound-gateway session-factory="smbSessionFactory"
request-channel="trigger"
reply-channel="nullChannel"
remote-directory="/"
auto-create-directory="true"
command="get"
expression="'smbtest.txt'"
local-directory="tmp/"
auto-create-local-directory="true"/>
<bean id="smbSessionFactory" class="org.springframework.integration.smb.session.SmbSessionFactory">
<property name="host" value="localhost"/>
<property name="domain" value=""/>
<property name="username" value="username"/>
<property name="password" value="password"/>
<property name="shareAndDir" value="test"/>
</bean>
Expected behavior
The file is created in the auto-created 'tmp' local directory.