file downloading from ftp server in iOS applicatio

2020-03-06 03:33发布

can we download a file from a ftp server using iOS sdk's API or by any other way. i know that through http request we can download files from server. so can we download file from ftp server in same way or is there any different sets of API for ftp.

Thanks

1条回答
▲ chillily
2楼-- · 2020-03-06 03:50
NSURL *url = [NSURL URLWithString:@"ftp://user:password@host:port/path"];
NSData *data = [[NSData alloc] initWithContentsOfURL:url];

Then you will get the file into data.


SWIFT:

var url = URL(string: "ftp://testUser:testPassword@191.122.0.12:20/ScheduleProject/Database/User.json")  //sudo code: URL(string: "ftp://user:password@host:port/path")
var data: Data? = nil
if let anUrl = url {
    data = Data(contentsOf: anUrl)
}
查看更多
登录 后发表回答