0

Ok. I am a bit of a new developer and haven't done much work with networking (in general, not specifically obj-c). Basically, I need to record a file (I have code to do this), then upload it to a server. I've looked at code to upload to servers and it seems that all I need from the server side of things is a html upload page with a php script, which I have. Another option would be ftp/sftp, although this would be harder to implement. The problem is I need to have authentication for the upload, and preferably have a secure (https) upload, with a username and password. I cannot figure out how to do this. I would also need the server to send back a response to the app.

Also, are their any frameworks to make it easier to upload files? I know there was asihttprequest, but that was discontinued...

What would I need to make the server do to have authentication and authenticated uploads, and be able to return data back to the app? Sorry for such a n00by question, but if you could help that would be great.

Thanks

benjih555
  • 931
  • 2
  • 10
  • 25

1 Answers1

0

Check out AFNetworking. I really enjoy doing file downloads and uploads using AFNetworking. The FAQ even gives an example on how to upload a file and download a file. All you need server side is a PHP script to handle a POST file upload.

Chris McKnight
  • 8,540
  • 4
  • 29
  • 31
  • That looks good, do you know of a way to add authentication using this framework? – benjih555 Jul 27 '12 at 15:00
  • Yes, you can leverage the power of the `AFHTTPClient` class, http://afnetworking.org/Documentation/Classes/AFHTTPClient.html. It has methods for setting headers for authentication. You can use `setAuthorizationHeaderWithToken:` if you use an API Token or you can use `setAuthorizationHeaderWithUsername:password:` if you use username and password – Chris McKnight Jul 27 '12 at 15:49
  • I actually prefer subclassing AFHTTPClient and setting the properties now. This is a better way to create a specialized API client for your application. In the overridden designated initializer, you can setup authentication or you can create your own designated initializer to pass in authentication as parameters. – Chris McKnight Apr 06 '16 at 21:48