Upload files to ftp from iOS application

2019-02-13 19:56发布

问题:

I read the SimpleFTPSample but I need an example better than this document. I Google'd some other examples but all the sites I found ended up referring to the Apple document, and I haven't found anything else that doesn't.

Can someone help me? Thanks.

回答1:

Wrote an easy to use ftp uploader for iOS and it runs on a background thread courtesy of ASIHTTPReq.

https://github.com/soulslicer/QueueFTP



回答2:

I believe you can do this with ASIHttpRequest, which is very powerfull.

From their doc:

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

// Upload a file on disk
[request setFile:@"/Users/ben/Desktop/ben.jpg" withFileName:@"myphoto.jpg" andContentType:@"image/jpeg"
forKey:@"photo"];

// Upload an NSData instance
[request setData:imageData withFileName:@"myphoto.jpg" andContentType:@"image/jpeg" forKey:@"photo"];

and

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request addPostValue:@"Ben" forKey:@"names"];
[request addPostValue:@"George" forKey:@"names"];
[request addFile:@"/Users/ben/Desktop/ben.jpg" forKey:@"photos"];
[request addData:imageData withFileName:@"george.jpg" andContentType:@"image/jpeg" forKey:@"photos"];

In your case url would be an FTP url, e.g.: ftp://user:password@my.host.com

But that won't do it for you or your requirement is to make a ftp client, Have a look at these:

  • https://github.com/valentinradu/WhiteRaccoon
  • https://github.com/jkichline/ACFTP
  • https://github.com/jkichline/ACConnect


回答3:

You may also want to look at Black Raccoon which is a light FTP file system and is actively maintained.