111.12. 更改目录的步骤
在消耗文件时(例如下载)或生成文件(例如上传)时,Camel FTP 可以在两种模式下操作。
- stepwise
- Not stepwise
根据您的情况和安全问题,您可能需要选择一个。有些 Camel 最终用户只能在使用步骤时下载文件,而其他 Camel 最终用户只能下载这些文件。您至少可以选择(来自 Camel 2.6 开始)。
在 Camel 2.0 - 2.5 中,只有一个模式,它是:
- 在 2.5 之前,不要采取措施
- 2.5 步骤
从 Camel 2.6 开始,您现在可以使用一个选项步骤 来控制行为。
请注意,在大多数情况下,对目录进行分步更改只有在用户仅限于其主目录以及主目录报告为 "/" 时才起作用。
其中一个两者之间的差别最好在示例中进行说明。假设我们在远程 FTP 服务器上有以下目录结构,我们需要遍历和下载文件:
/
/one
/one/two
/one/two/sub-a
/one/two/sub-b
并且我们在每个子 A (a.txt)和 sub-b (b.txt)文件夹中都有一个文件。
111.12.1. 使用 stepwise=true (默认模式) 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
TYPE A
200 Type set to A
PWD
257 "/" is current directory.
CWD one
250 CWD successful. "/one" is current directory.
CWD two
250 CWD successful. "/one/two" is current directory.
SYST
215 UNIX emulated by FileZilla
PORT 127,0,0,1,17,94
200 Port command successful
LIST
150 Opening data channel for directory list.
226 Transfer OK
CWD sub-a
250 CWD successful. "/one/two/sub-a" is current directory.
PORT 127,0,0,1,17,95
200 Port command successful
LIST
150 Opening data channel for directory list.
226 Transfer OK
CDUP
200 CDUP successful. "/one/two" is current directory.
CWD sub-b
250 CWD successful. "/one/two/sub-b" is current directory.
PORT 127,0,0,1,17,96
200 Port command successful
LIST
150 Opening data channel for directory list.
226 Transfer OK
CDUP
200 CDUP successful. "/one/two" is current directory.
CWD /
250 CWD successful. "/" is current directory.
PWD
257 "/" is current directory.
CWD one
250 CWD successful. "/one" is current directory.
CWD two
250 CWD successful. "/one/two" is current directory.
PORT 127,0,0,1,17,97
200 Port command successful
RETR foo.txt
150 Opening data channel for file transfer.
226 Transfer OK
CWD /
250 CWD successful. "/" is current directory.
PWD
257 "/" is current directory.
CWD one
250 CWD successful. "/one" is current directory.
CWD two
250 CWD successful. "/one/two" is current directory.
CWD sub-a
250 CWD successful. "/one/two/sub-a" is current directory.
PORT 127,0,0,1,17,98
200 Port command successful
RETR a.txt
150 Opening data channel for file transfer.
226 Transfer OK
CWD /
250 CWD successful. "/" is current directory.
PWD
257 "/" is current directory.
CWD one
250 CWD successful. "/one" is current directory.
CWD two
250 CWD successful. "/one/two" is current directory.
CWD sub-b
250 CWD successful. "/one/two/sub-b" is current directory.
PORT 127,0,0,1,17,99
200 Port command successful
RETR b.txt
150 Opening data channel for file transfer.
226 Transfer OK
CWD /
250 CWD successful. "/" is current directory.
QUIT
221 Goodbye
disconnected.
正如您在启用步骤范围时所看到的那样,它将使用 CD xxx 遍历目录结构。
111.12.2. 使用 stepwise=false 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
230 Logged on
TYPE A
200 Type set to A
SYST
215 UNIX emulated by FileZilla
PORT 127,0,0,1,4,122
200 Port command successful
LIST one/two
150 Opening data channel for directory list
226 Transfer OK
PORT 127,0,0,1,4,123
200 Port command successful
LIST one/two/sub-a
150 Opening data channel for directory list
226 Transfer OK
PORT 127,0,0,1,4,124
200 Port command successful
LIST one/two/sub-b
150 Opening data channel for directory list
226 Transfer OK
PORT 127,0,0,1,4,125
200 Port command successful
RETR one/two/foo.txt
150 Opening data channel for file transfer.
226 Transfer OK
PORT 127,0,0,1,4,126
200 Port command successful
RETR one/two/sub-a/a.txt
150 Opening data channel for file transfer.
226 Transfer OK
PORT 127,0,0,1,4,127
200 Port command successful
RETR one/two/sub-b/b.txt
150 Opening data channel for file transfer.
226 Transfer OK
QUIT
221 Goodbye
disconnected.
正如您在不使用步骤时所看到的那样,根本没有调用 CD 操作。