简体   繁体   English

iOS:如何在上传时检查FTP服务器上是否已存在目录?

[英]iOS:How to check if an directory already exists on the FTP server while uploading?

I am working on an App, in which I want to upload images and pdf to the FTP server. 我正在开发一个应用程序,我想将图像和pdf上传到FTP服务器。 I am using this reference ref .All is working good. 我正在使用这个参考参考 。所有工作都很好。 The images and pdf are getting uploaded on the server with proper names and sizes. 图像和pdf将以适当的名称和大小上载到服务器上。

But, now I want to check if the directory is already exists on the server or not. 但是,现在我想检查服务器上是否已存在该目录。 I am not able to get it to work with this library. 我无法使用此库。

So my question is that how to check directory on ftp,if directory is there then upload the files if not then first create directory on ftp and then upload files onto that directory? 所以我的问题是如何检查ftp上的目录,如果目录在那里然后上传文件,如果没有那么先在ftp上创建目录然后将文件上传到该目录?

Any Ideas.. ? 有任何想法吗.. ? Any help will be appreciated. 任何帮助将不胜感激。

Different FTP servers will answer the LIST request in differing ways, so there is no single answer to this question. 不同的FTP服务器将以不同的方式回答LIST请求,因此这个问题没有单一的答案。 RFC959 says on the matter: RFC959就此事说:

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 the CWD request to change into the directory in question, and detecting a successful response will detect the directory, however that leaves you in that directory as a potentially unrequired side effect. 使用CWD请求更改到相关目录,并检测到成功的响应将检测目录,但是这会使您该目录中作为潜在的不需要的副作用。

For these reasons, as well as others, you may find more modern protocols such as SSH (which includes a file transfer feature) to be more useful. 出于这些原因,以及其他原因,您可能会发现更多现代协议(如SSH(包括文件传输功能))更有用。 You may find the DLSFTPClient CocoaPod useful. 您可能会发现DLSFTPClient CocoaPod很有用。

M. M.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM