使用Swift 4/5的FTP(带有/不带有额外框架) [英] FTP with Swift 4/5 (with/without extra framework)

查看:74
本文介绍了使用Swift 4/5的FTP(带有/不带有额外框架)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先:我知道有关ftp的安全问题,所以请在此不做任何讨论-必须使用ftp.

First of all: I know about the security concerns regarding ftp, so please no discussion about this here - ftp has to be used.

我的应用必须使用ftp(使用用户名/密码)登录到服务器,搜索并下载文件,将其从服务器中删除,然后上传编辑后的版本.

My app has to log into a server with ftp (with username/password), search for and download a file, delete it from the server, then upload an edited version.

我一直在寻找有关如何甚至通过ftp与服务器建立连接的教程,但我发现的只是2012年苹果公司的文档

I've been searching for tutorials on how to even get a connection to a server via ftp but all I found were Apple's documentation from 2012 here and their documentation about the different functions here (and a bunch of weird "Swift FTP" biking videos on youtube...). Every other example I found (usually <2015) uses some additional framework or library but there don't seem to be any proper tutorial for Swift 5 or even Swift 4.

在Swift 5上甚至还可以使用FTP(是否仍受支持?),如果可以,怎么办?还是只是没有任何意义试图使Apple的任何东西正常工作并且更好地使用诸如 FileProvider ?

Is it even still possible to use FTP with Swift 5 (is it still supported?) and if so, how? Or is there simply no point trying to get any of Apple's stuff to work and better to just use an extra framework like FileProvider?

推荐答案

起初,我使用的是 FileProvider ,不幸的是,该库当前存在很多错误,函数被调用了两次(可以通过使用"firstTimeCalled" bool检查来防止),并且如果服务器运行缓慢(-ish),则也可能无法获取例如目录中文件的完整列表,因为FileProvider在服务器实际完成之前停止接收答案.

At first I was using FileProvider, unfortunately the library is pretty buggy currently, with functions being called twice (which you can kind of prevent by using a "firstTimeCalled" bool check) and if the server's slow(-ish), you also might not get e.g. the full list of files in a directory because FileProvider stops receiving answers before the server's actually done.

我还没有找到其他可以正常工作的Swift库FTP库(并且仍然受支持),所以现在我在使用

I haven't found any other FTP libraries for Swift that work (and are still supported), so now I'm using BlueSocket (which is able to open sockets, send commands to the server and receive commands from it) and built my own small library that can send/receive,... files (using the FTP codes) around it.

这篇关于使用Swift 4/5的FTP(带有/不带有额外框架)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆