• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Upload large file using HTTP request
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Upload large file using HTTP request


  • Subject: Re: Upload large file using HTTP request
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 19 Jun 2008 16:28:40 -0700


On 19 Jun '08, at 3:17 PM, James Bucanek wrote:

My idea was to create a single ZIP file with the data and send it to a special Java Server Page on my Xserve via an HTTP request. The JSP page would then unzip the file and digest the results.

This is pretty easy. You'd create an NSMutableURLRequest, then call - setHTTPMethod: to change the method to "POST". Since the body is large you'll probably want to use -setHTTPBodyStream:. If you have the body in a file, you just need to open an NSInputStream on that.


Then create an NSURLConnection with the request, and set an object as the delegate. You'll get called back with progress information. (Or if you don't mind doing it synchronously, there's a class method on NSURLConnection for sending a synchronous request.)

I know that an HTML page can be set up to upload a file as part of a form. I believe it's just a matter of creating a multi-part form request with the correct encoding type.

You only need to do that if you have an existing server-side handler that already processes a form with a file-upload in it.


If you're going to be implementing a new handler on the server just for this, it's easier just to read the body of the HTTP request directly. That way the client code doesn't have to worry about encoding it into any other format.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Upload large file using HTTP request (From: James Bucanek <email@hidden>)

  • Prev by Date: Upload large file using HTTP request
  • Next by Date: CFWriteStreamWrite Blocking if we give invalid Host.
  • Previous by thread: Upload large file using HTTP request
  • Next by thread: Re: Upload large file using HTTP request
  • Index(es):
    • Date
    • Thread