我们可以使用iOS sdk的API或任何其他方式从ftp服务器下载文件。 我知道通过http请求我们可以从服务器下载文件。那么我们可以用同样的方式从ftp服务器下载文件,还是有任何不同的ftp集合。
由于
答案 0 :(得分:3)
NSURL *url = [NSURL URLWithString:@"ftp://user:password@host:port/path"];
NSData *data = [[NSData alloc] initWithContentsOfURL:url];
然后您将把文件导入data
。
<强> SWIFT:强>
var url = URL(string: "ftp://user:password@host:port/path")
var data: Data? = nil
if let anUrl = url {
data = Data(contentsOf: anUrl)
}