Comments (17)
Sounds like a good idea. Can you specify more details how they would work? What would the method signatures look like?
- CopyFile(string src, string dest, bool overwrite = true)
- CopyDirectory(string src, string dest, bool overwrite = true)
- MoveFile(string src, string dest, bool overwrite = true)
- MoveDirectory(string src, string dest, bool overwrite = true)
I think move file is similar to rename?
from fluentftp.
Hi,
The signatures look reasonable. I guess the only thing that may be added somewhere is the FtpListOption as that would affect how files/folders are discovered.
In terms of how they would work.... In my head they would be an all or nothing operation without any form of transactional support. So if you were moving a directory tree and ran into issues along the way the method would return false and throw some form of exception.
Move file is not totally similair to rename as move might change location and name of the file.
from fluentftp.
Approximately how will these commands work? I need some more info before I can begin implementing this.
- CopyFile
- download file to disk/stream (direct server to server is not possible with FTP, only SFTP can do that)
- upload file to server
- CopyDirectory
- download entire folder recursively to disk (not into memory since it can be too big???)
- upload directory to server, file by file
- MoveFile
- same as Rename? can Rename be used to move a file from X to Y?
- if you can do some tests with Rename to check its behavior it would speed up the implementation of this feature
- MoveDirectory
- same as Rename? can Rename be used to move an entire folder?
- if you can do some tests with Rename to check its behavior it would speed up the implementation of this feature
from fluentftp.
@natiki - Can you check if the above pseudo code looks ok so I can begin implementing it?
from fluentftp.
@hgupta9 Have not forgotten about this. Will let you know in a couple of days.
from fluentftp.
Can you respond please?
from fluentftp.
Apologies for the delay....
You should have a look at the FTP commands RNFR and RNTO as these will allow you to do the above operations on the server without the need to download the files and upload them again. Below is an example of me moving a folder /Blah to /Blah3
[08:39:51] [R] MKD /Blah3
[08:39:51] [R] 257-"/Blah3" : The directory was successfully created
[08:39:51] [R] 257 224130 Kbytes used (10%) - authorized: 2097152 Kb
[08:40:13] [R] CWD /Blah
[08:40:13] [R] 250 OK. Current directory is /Blah
[08:40:13] [R] PWD
[08:40:13] [R] 257 "/Blah" is your current location
[08:40:13] [R] CWD /Blah3
[08:40:13] [R] 250 OK. Current directory is /Blah3
[08:40:13] [R] PWD
[08:40:13] [R] 257 "/Blah3" is your current location
[08:40:13] [R] CWD /
[08:40:13] [R] 250 OK. Current directory is /
[08:40:13] [R] PWD
[08:40:13] [R] 257 "/" is your current location
[08:40:13] [R] PASV
[08:40:13] [R] 227 Entering Passive Mode (118,127,42,204,117,178)
[08:40:13] [R] Opening data connection IP: 118.127.42.204 PORT: 30130
[08:40:13] [R] MLSD
[08:40:13] [R] 150 Accepted data connection
[08:40:13] [R] 226-Options: -a -l
[08:40:13] [R] 226 6 matches total
[08:40:13] [R] List Complete: 659 bytes in 0.04 seconds (0.6 KB/s)
[08:40:13] [R] RNFR /Blah/sample.pas.txt
[08:40:13] [R] 350 RNFR accepted - file exists, ready for destination
[08:40:13] [R] RNTO /Blah3/sample.pas.txt
[08:40:13] [R] 250 File successfully renamed or moved
[08:40:13] [R] RNFR /Blah/template.info
[08:40:13] [R] 350 RNFR accepted - file exists, ready for destination
[08:40:13] [R] RNTO /Blah3/template.info
[08:40:13] [R] 250 File successfully renamed or moved
[08:40:13] [R] PASV
[08:40:13] [R] 227 Entering Passive Mode (118,127,42,204,133,106)
[08:40:13] [R] Opening data connection IP: 118.127.42.204 PORT: 34154
[08:40:13] [R] MLSD
[08:40:13] [R] 150 Accepted data connection
[08:40:13] [R] 226-Options: -a -l
[08:40:13] [R] 226 6 matches total
[08:40:13] [R] List Complete: 659 bytes in 0.04 seconds (0.6 KB/s)
[08:40:13] Transfer queue completed
[08:40:13] Transferred 0 Files (0 bytes) in 0.21 seconds (0.0 KB/s)
I would guess you could do all operations this way even copy as long as you generated a new name to avoid name conflicts.
from fluentftp.
That's amazing! I will look into supporting these FTP commands.
from fluentftp.
I just checked the code and Rename does exactly that. It first executes RNFR and if it succeeds it executes RNTO. It can be used as a backend for MoveFile and MoveDirectory. However for copying we will first have to download and re-upload.
from fluentftp.
Well for copy you could do the same as the above if you generate a temporary top level name and then change it to what it needs to be etc. as long as there is no conflict.
from fluentftp.
But how would we preserve the source file/dir if we have moved it to a new path?
from fluentftp.
Have a look at FXP https://en.wikipedia.org/wiki/File_eXchange_Protocol. If the server supports it then you don't have to download first.
from fluentftp.
Its complicated but sounds decent enough once implemented. To add to the fact that most servers have it disabled .. "As a result of this, FTP server software often has FXP disabled by default."
I think downloading and uploading seems like a simple enough solution until this FXP system can be implemented.
from fluentftp.
Implemented MoveFile() and MoveDirectory() in trunk. Advantages over Rename() include :
- In Skip mode, if the dest already exists the operation is skipped
- In Overwrite mode, if the dest already exists it is deleted first, and then the Rename() is performed
from fluentftp.
Will you implement FXP?
from fluentftp.
@sergeu90 To add to the fact that most servers have FXP disabled .. "As a result of this, FTP server software often has FXP disabled by default."
from fluentftp.
Moving files between the directories in server was exactly what i needed. I couldn't find it in the examples, searched it on google and got me here. Thanks a lot
from fluentftp.
Related Issues (20)
- Progress should include all operations of a single file transfer HOT 16
- Problem transfering file with particular FXP destination server HOT 4
- DownloadStream method ignores stopPosition HOT 2
- Download with stopPosition overdownloads within last chunk, breaks progress report too HOT 7
- Multi-File operations should provide a overall progress HOT 13
- How often do you update NuGet? HOT 2
- Release page and release tags are missing HOT 1
- Request for Nuget 49.0.2 HOT 4
- Question about 'DownloadDirectory()' HOT 1
- Error using clone function with async client HOT 5
- Disposing a connected AsyncFtpClient throws non-fatal System.InvalidCastException in version 49.0.* HOT 42
- System.InvalidCastException exception Thrown After File Upload Completes HOT 1
- Reuse Connection? HOT 3
- Error 550 file not found HOT 1
- ACTIVE mode FTP is raising Exception of Timeout but working in FileZilla and WinSCP HOT 7
- Resume Progress Problem
- timeout exception after download and upload all bytes HOT 8
- GetListing during DownloadFile/UploadFile async error HOT 4
- The AsyncFtpClientSocks5Proxy.cs need Add code HOT 2
- Connection lost between server and client not handled. HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentftp.