Copying files internally on an SFTP server using Spring integration/JCraft JSch
up vote
1
down vote
favorite
I was wondering if there is a way to copy files on an SFTP server to another directory on the same SFTP server. I want to do this without getting the file in a client and then setting it in the other folder. Of course this would work fine but I guess that this would produce more overhead, so I would like to avoid this if at all possible. I'm currently working with Spring integration which is based on JCraft JSch.
So far I haven't been able to find any way to do this without an intermediary.
Another approach would be to open an SSH channel and just use the cp
command but well that's not too pretty either in my opinion.
Thanks in advance!
java spring copy sftp jsch
add a comment |
up vote
1
down vote
favorite
I was wondering if there is a way to copy files on an SFTP server to another directory on the same SFTP server. I want to do this without getting the file in a client and then setting it in the other folder. Of course this would work fine but I guess that this would produce more overhead, so I would like to avoid this if at all possible. I'm currently working with Spring integration which is based on JCraft JSch.
So far I haven't been able to find any way to do this without an intermediary.
Another approach would be to open an SSH channel and just use the cp
command but well that's not too pretty either in my opinion.
Thanks in advance!
java spring copy sftp jsch
You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
– Castaglia
Jun 6 '16 at 19:29
Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
– Roddy of the Frozen Peas
Nov 9 at 23:16
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I was wondering if there is a way to copy files on an SFTP server to another directory on the same SFTP server. I want to do this without getting the file in a client and then setting it in the other folder. Of course this would work fine but I guess that this would produce more overhead, so I would like to avoid this if at all possible. I'm currently working with Spring integration which is based on JCraft JSch.
So far I haven't been able to find any way to do this without an intermediary.
Another approach would be to open an SSH channel and just use the cp
command but well that's not too pretty either in my opinion.
Thanks in advance!
java spring copy sftp jsch
I was wondering if there is a way to copy files on an SFTP server to another directory on the same SFTP server. I want to do this without getting the file in a client and then setting it in the other folder. Of course this would work fine but I guess that this would produce more overhead, so I would like to avoid this if at all possible. I'm currently working with Spring integration which is based on JCraft JSch.
So far I haven't been able to find any way to do this without an intermediary.
Another approach would be to open an SSH channel and just use the cp
command but well that's not too pretty either in my opinion.
Thanks in advance!
java spring copy sftp jsch
java spring copy sftp jsch
edited Jun 6 '16 at 20:09
Martin Prikryl
83.4k22154342
83.4k22154342
asked Jun 6 '16 at 18:38
user3157264
44210
44210
You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
– Castaglia
Jun 6 '16 at 19:29
Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
– Roddy of the Frozen Peas
Nov 9 at 23:16
add a comment |
You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
– Castaglia
Jun 6 '16 at 19:29
Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
– Roddy of the Frozen Peas
Nov 9 at 23:16
You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
– Castaglia
Jun 6 '16 at 19:29
You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
– Castaglia
Jun 6 '16 at 19:29
Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
– Roddy of the Frozen Peas
Nov 9 at 23:16
Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
– Roddy of the Frozen Peas
Nov 9 at 23:16
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
A core SFTP protocol does not support duplicating a remote file.
There's a draft of copy-file
extension to the protocol, but that's supported by only few SFTP servers (ProFTPD/mod_sftp and Bitvise SFTP server for example).
It's definitely not supported by the most widespread OpenSSH SFTP server.
And it's also not supported by the JSch library.
See also my answer to How can I copy/duplicate a file to another directory using SFTP?
So actually using the cp
shell command over an "exec" channel (ChannelExec
) is unfortunately the best available approach (assuming you connect to a *nix server and you have a shell access).
If you do not have a shell access, then your only option is indeed to download the file to a local temporary folder and upload it back to the new location (or use streams, to avoid a temporary file). See also:
- How do I transfer a file from one directory to another using Java SFTP Library JSch?
- How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
– user3157264
Jun 6 '16 at 20:40
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
A core SFTP protocol does not support duplicating a remote file.
There's a draft of copy-file
extension to the protocol, but that's supported by only few SFTP servers (ProFTPD/mod_sftp and Bitvise SFTP server for example).
It's definitely not supported by the most widespread OpenSSH SFTP server.
And it's also not supported by the JSch library.
See also my answer to How can I copy/duplicate a file to another directory using SFTP?
So actually using the cp
shell command over an "exec" channel (ChannelExec
) is unfortunately the best available approach (assuming you connect to a *nix server and you have a shell access).
If you do not have a shell access, then your only option is indeed to download the file to a local temporary folder and upload it back to the new location (or use streams, to avoid a temporary file). See also:
- How do I transfer a file from one directory to another using Java SFTP Library JSch?
- How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
– user3157264
Jun 6 '16 at 20:40
add a comment |
up vote
1
down vote
accepted
A core SFTP protocol does not support duplicating a remote file.
There's a draft of copy-file
extension to the protocol, but that's supported by only few SFTP servers (ProFTPD/mod_sftp and Bitvise SFTP server for example).
It's definitely not supported by the most widespread OpenSSH SFTP server.
And it's also not supported by the JSch library.
See also my answer to How can I copy/duplicate a file to another directory using SFTP?
So actually using the cp
shell command over an "exec" channel (ChannelExec
) is unfortunately the best available approach (assuming you connect to a *nix server and you have a shell access).
If you do not have a shell access, then your only option is indeed to download the file to a local temporary folder and upload it back to the new location (or use streams, to avoid a temporary file). See also:
- How do I transfer a file from one directory to another using Java SFTP Library JSch?
- How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
– user3157264
Jun 6 '16 at 20:40
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
A core SFTP protocol does not support duplicating a remote file.
There's a draft of copy-file
extension to the protocol, but that's supported by only few SFTP servers (ProFTPD/mod_sftp and Bitvise SFTP server for example).
It's definitely not supported by the most widespread OpenSSH SFTP server.
And it's also not supported by the JSch library.
See also my answer to How can I copy/duplicate a file to another directory using SFTP?
So actually using the cp
shell command over an "exec" channel (ChannelExec
) is unfortunately the best available approach (assuming you connect to a *nix server and you have a shell access).
If you do not have a shell access, then your only option is indeed to download the file to a local temporary folder and upload it back to the new location (or use streams, to avoid a temporary file). See also:
- How do I transfer a file from one directory to another using Java SFTP Library JSch?
- How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
A core SFTP protocol does not support duplicating a remote file.
There's a draft of copy-file
extension to the protocol, but that's supported by only few SFTP servers (ProFTPD/mod_sftp and Bitvise SFTP server for example).
It's definitely not supported by the most widespread OpenSSH SFTP server.
And it's also not supported by the JSch library.
See also my answer to How can I copy/duplicate a file to another directory using SFTP?
So actually using the cp
shell command over an "exec" channel (ChannelExec
) is unfortunately the best available approach (assuming you connect to a *nix server and you have a shell access).
If you do not have a shell access, then your only option is indeed to download the file to a local temporary folder and upload it back to the new location (or use streams, to avoid a temporary file). See also:
- How do I transfer a file from one directory to another using Java SFTP Library JSch?
- How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
edited Nov 19 at 10:22
answered Jun 6 '16 at 20:07
Martin Prikryl
83.4k22154342
83.4k22154342
Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
– user3157264
Jun 6 '16 at 20:40
add a comment |
Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
– user3157264
Jun 6 '16 at 20:40
Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
– user3157264
Jun 6 '16 at 20:40
Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
– user3157264
Jun 6 '16 at 20:40
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37664612%2fcopying-files-internally-on-an-sftp-server-using-spring-integration-jcraft-jsch%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
– Castaglia
Jun 6 '16 at 19:29
Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
– Roddy of the Frozen Peas
Nov 9 at 23:16