【发布时间】:2020-02-24 10:52:06
【问题描述】:
我需要在SFTPOutboundGateway 中使用更多命令(cd、mkdir、rmdir),但根据the official documentation,只有少数命令可用,我需要的其他命令都没有。这背后有什么原因吗?是否有(其他)方法可以使用更多命令,例如 cd、mkdir 和 rmdir ?
【问题讨论】:
标签: spring-integration spring-integration-sftp
我需要在SFTPOutboundGateway 中使用更多命令(cd、mkdir、rmdir),但根据the official documentation,只有少数命令可用,我需要的其他命令都没有。这背后有什么原因吗?是否有(其他)方法可以使用更多命令,例如 cd、mkdir 和 rmdir ?
【问题讨论】:
标签: spring-integration spring-integration-sftp
cd 在网关中毫无意义,因为它实际上什么都不做。
对于网关不支持的命令,请在服务激活器中使用您的代码中的SftpRemoteFileGateway。
模板不支持的命令,使用
/**
* Execute the callback's doInSession method after obtaining a session.
* Reliably closes the session when the method exits.
*
* @param callback the SessionCallback.
* @param <T> The type returned by
* {@link SessionCallback#doInSession(org.springframework.integration.file.remote.session.Session)}.
* @return The result of the callback method.
*/
<T> T execute(SessionCallback<F, T> callback);
和
@FunctionalInterface 公共接口 SessionCallback {
/**
* Called within the context of a session.
* Perform some operation(s) on the session. The caller will take
* care of closing the session after this method exits.
*
* @param session The session.
* @return The result of type T.
* @throws IOException Any IOException.
*/
T doInSession(Session<F> session) throws IOException;
}
Session 不支持的命令,使用
/**
* Get the underlying client library's client instance for this session.
* Returns an {@code Object} to avoid significant changes to -file, -ftp, -sftp
* modules, which would be required
* if we added another generic parameter. Implementations should narrow the
* return type.
* @return The client instance.
* @since 4.1
*/
Object getClientInstance();
@Override
public ChannelSftp getClientInstance() {
return this.channel;
}
直接在JSch客户端上操作。
【讨论】:
SftpOutboundGateway 获得?