IPhone/iPod Touch file transfer solution-cocoa Web Resource Project

Source: Internet
Author: User
Tags http authentication ftp transfer

So far, that is, iPhone SDK 2.2, Apple still does not provide a file transfer solution for developers. If an application needs to provide users with the ability to upload files to the iPhone, it will use one of the following methods:

  1. Download from the Internet through a link.
  2. Provides a client for uploading through its own protocol.
  3. Supports FTP transfer protocol.
  4. Start an HTTP service on the iPhone and upload it through a browser.
  5. Further than the previous one, WebDAV is supported on HTTP and uploaded through Protocol modification.

These methods have their own advantages and disadvantages. Although the development in the first two methods is relatively simple, the user operations are not convenient, and fewer methods are used. Using FTP requires additional client software On some systems, which is not convenient. The WebDAV Method is now popular, and both air sharing and discover adopt this method.

When using the iPhone ichm, you also need to provide the file upload function. I chose the fourth solution, that is, to provide an HTTP service for uploading through a browser. Although this scheme cannot be directly mounted to a file system like WebDAV in some systems, it does not need to install additional clients for almost all systems with browsers, it is much easier to implement than WebDAV.

In the selection of HTTP server, you can porting existing mature products, but for such applications, Apache or Lighttpd solutions are too complex, in fact, just a very simple service. Finally, we found the cocoahttpserver, which is an open-source project by deusty designs. It supports asynchronous socket, IPv4 and IPv6, HTTP Authentication and TLS encryption, which is small and exquisite. Except for the get method, all others can be said to have and none of them are.

I have extended cocoahttpserver, and first realized the support for multipart POST. In the design of the file transfer function, I use files as a resource and use the rest method:

Method Function
Get File List, File Download
Post Upload new files
Delete File Deletion

This design is clear from the interface and implementation perspectives.

After ichm 1.0 was released, it was relatively stable after ichm 1.0.1. Now I will transfer this part of the code Open Source:
Cocoa Web Resource Project
The main functions are as follows:

  • You can use a browser to upload files to the iPhone/iPod Touch, and download and delete files.
  • Memory is optimized and supports uploading large files.
  • Customizable web interface.
  • Web interfaces support mainstream browsers such as IE, Safari, and Firefox.
  • Restful API.

I hope it will help iPhone developers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.