Exporting files over WIFI to a computer from an iPhone app - use NSNetService?

Discussion in 'iOS Programming' started by johnnyjibbs, May 17, 2009.

  1. johnnyjibbs macrumors 68030

    johnnyjibbs

    Joined:
    Sep 18, 2003
    Location:
    London, UK
    #1
    Hi all,

    I'm hoping that someone could point me in the right direction as I have no experience of network programming. I need to give the user the ability to export a file to their computer via WIFI (like an FTP server), much like certain apps such as AirSharing do by displaying a web address (e.g. http://192.168.3.1:8080) that the user simply types into their computer web browser to access the files.

    But I cannot find anything on the internet that points me in the direction of how to implement this. I've followed the code to publish a network service using Apple's NSNetSerice and CFNetService Programming Guide and although it builds and runs, it does not show up anywhere from my Mac and I don't know how to specify the web address. I have no knowledge of TCP or what it does.

    Furthermore, none of the Apple provided sample projects (WiTap, BonjourWeb, Cryptoblahblah) seem to help do what I want (and they're really complicated as well)

    Does anyone know if I'm going along the right track or if there is any advice I could follow? I would be happy to post some sample code if you like.

    Many thanks in advance.

    John
     
  2. johnnyjibbs thread starter macrumors 68030

    johnnyjibbs

    Joined:
    Sep 18, 2003
    Location:
    London, UK
    #2
    Well, I'm still scratching my head on this one but I may be a step closer: I've found this Apple example for Mac, which looks like it may do a lot of what I want (assuming I can port it to iPhone with no problems). Problem is, I'm on a Windows computer at the moment so will have to wait until tonight to test what the app does on my Mac.
     
  3. johnnyjibbs thread starter macrumors 68030

    johnnyjibbs

    Joined:
    Sep 18, 2003
    Location:
    London, UK
    #3
    Bingo! The guys at Deusty have created a brilliant embedable HTTP server for Mac OS X and iPhone. They have released it as open source for anyone to use! Several apps in the app store already use it.

    Simply take the xcode project and drop the classes into your project, tweaking the interface as neccessary!

    If anyone else is interested in saving a lot of hair-tearing, you can download iPhoneHTTPServer from here.

    Now when a user taps 'export' in my app, it publishes a WIFI service (accessible via any web browser at http://192.168.etc.etc or using Bonjour) that links to my app's Documents directory with clickable links to download the files. It even supports file upload if you so wish!!!

    Many thanks Deusty! :)
     

Share This Page