IOS: How to check if directory exists on FTP server on upload?

I am working on an application where I want to upload images and PDF to an FTP server. I am using this ref . Everything works well. Images and PDFs are uploaded to the server with names and sizes.

But now I want to check if the directory exists on the server or not. I cannot get it to work with this library.

So my question is how to check the directory on ftp, if there is a directory, upload the files, if not, first create a directory on ftp and then upload the files to that directory?

Any ideas ..? Any help would be appreciated.

+3


source to share


1 answer


Different FTP servers will respond to the request in LIST

different ways, so there is no single answer to this question. RFC959 says on the matter:

Since the information on a file may vary widely from system
to system, this information may be hard to use automatically
in a program, but may be quite useful to a human user.

      

Using a request CWD

to move to the appropriate directory, and the discovery of a successful response will detect the directory, but it leaves in this directory as a potential side effect of the crude.



For these reasons, as well as others, you might find more modern protocols like SSH (which includes a file transfer feature) to be more useful. You can find DLSFTPClient CocoaPod.

M.

0


source







All Articles