1

I've created a Python script that copies a file from an FTP ServerA to another FTP ServerB when a certain condition happens.

Right now the copy works in this way:

ServerA -> tmp (temporary folder in the script) -> ServerB

I want to upgrade the script and remove the tmp folder so I want to have a directly copy from ServerA to ServerB.

I saw that this process can be done using FXP protocol but I cannot find a good guide or documentation about using it with Python (the only thing that I found is this one: https://ftpext.readthedocs.io/en/latest/index.html).

Can anyone help me figuring out better how does it work? Or, of course, of there is a better way to do it. The goal is don't need a temporary staging area.

0

1 Answer 1

1

With use of the FTPExt class, the code should be like:

source = FTPExt("source.example.com", 21, "source_user", "source_pass")
target = FTP("target.example.com", "target_user", "target_pass")

source.fxp_to("/source/path/file", target, "/target/path/file")

Though if you do not need any fancy feature, you do not need the FTPExt, there's ftpcp in ftplib that does the same as FTPExt.fxp_to:

ftpcp(source, "/source/path/file", target, "/target/path/file")

But! – Most FTP servers do not support FXP. Do you know if both your servers do? You should find out before you try to implement that. – If your servers do not support FXP, you can still do without a intermediate file, by streaming from one connection to another.

Sign up to request clarification or add additional context in comments.

3 Comments

I'm using two vsftpd server created with the docker image of Fauria (hub.docker.com/r/fauria/vsftpd). I will try your solution maybe tomorrow because now I'm working on another implementations way. In any case, thank you a lot for your answer!
I think that the ftp server that I'm using doesn't support FXP but I didn't spend much time on it because I choose to implement a different solution using SSH
Oh yeah sure, sorry I forget to do it :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.