Spring - 从 NAS 文件夹中提取文件
Spring - extract files from NAS folder
我正在尝试使用 Spring.
将一些文件从 NAS (Linux) 拉到本地计算机
我不想在 Spring 中使用 SFTP 会话,即使它可以工作...事实上,我曾经从 sftp 服务器中提取文件,但由于某种原因,现在我唯一拥有的资源是这个NAS。
有什么办法让它起作用吗?或者我必须自己写 class?
从这里引用 java read file from network device:
The simplest way to do this would be to read it using regular file paths.
On Windows:
new File("\\server\path\to\file.txt")
// (double-backslashes required for backslashes in path)
On Unix:
First mount the share using Samba (SMB, NFS or whatever other protocol) to some location like /mnt/network
. Then you can use:
new File("/mnt/network/path/to/file.txt")
Once you have the File object you can use FileInputStream
, FileReader
or whatever else you want to read the file in.
只要您能够将远程共享目录挂载到本地文件系统,您就可以轻松开始使用常规 Spring 集成:
<int-file:inbound-channel-adapter channel="files"
directory="/mnt/network/path/to/">
<int:poller fixed-delay="10000"/>
</int-file:inbound-channel-adapter>
我正在尝试使用 Spring.
将一些文件从 NAS (Linux) 拉到本地计算机我不想在 Spring 中使用 SFTP 会话,即使它可以工作...事实上,我曾经从 sftp 服务器中提取文件,但由于某种原因,现在我唯一拥有的资源是这个NAS。
有什么办法让它起作用吗?或者我必须自己写 class?
从这里引用 java read file from network device:
The simplest way to do this would be to read it using regular file paths.
On Windows:
new File("\\server\path\to\file.txt") // (double-backslashes required for backslashes in path)
On Unix:
First mount the share using Samba (SMB, NFS or whatever other protocol) to some location like
/mnt/network
. Then you can use:new File("/mnt/network/path/to/file.txt")
Once you have the File object you can use
FileInputStream
,FileReader
or whatever else you want to read the file in.
只要您能够将远程共享目录挂载到本地文件系统,您就可以轻松开始使用常规 Spring 集成:
<int-file:inbound-channel-adapter channel="files"
directory="/mnt/network/path/to/">
<int:poller fixed-delay="10000"/>
</int-file:inbound-channel-adapter>