Re: streaming upload of a file
Re: streaming upload of a file
- Subject: Re: streaming upload of a file
- From: "Alexey Proskuryakov" <email@hidden>
- Date: Wed, 22 Jun 2005 23:51:23 +0400
I have used a DTS support incident to ask for sample code doing exactly
this job; it is currently in progress. It may even result in a public
technote, otherwise, I will hopefully be able to post some detailed info when
I get it.
On Wed, 22 Jun 2005 11:11:02 -0700 Becky Willrich <email@hidden> wrote:
Hi Tracy -
What you need is to define your own kind of stream; the best way to do that
is unfortunately at the Foundation layer - you can subclass NSInputStream
and implement your own backing store to be the data you want followed by the
contents of the file you want.
Using only CFNetwork and below, your best bet is to create a temporary file
that's a copy of the data to be uploaded, then use plain ol' file system
calls to insert the extra bytes you need at the beginning, then create a
read stream from the temporary file and pass that to CFNetwork. Once the
stream has finished its work, you can delete the temporary file.
Hope that helps,
REW
On Jun 22, 2005, at 11:02 AM, Tracy Stampfli wrote:
I am using CFNetwork to upload files using HTTP POST multipart/form-
data requests. This works fine for small files, but I would like to
be able to upload larger files without having to read the entire
file into memory in order to create the body of the request.
Currently, since the body of my request has to include both the
file data and the form data (boundary strings, etc.). I create a
buffer, fill it with the form elements and file data, call
CFReadStreamCreateWithBytesNoCopy to get a stream from the buffer,
and then call CFReadStreamCreateForStreamedHTTPRequest to make my
request.
What I would like to do is get a stream to the file (with
CFReadStreamCreateWithFile, presumably) and create the request from
that stream, without reading the file into memory. The problem is
that if the file stream is used as the body of the request, I can't
include other any data in the body, like the form elements. Is
there any way to stream in the file as part of the body of the
request, but still add other data?
-Tracy
_______________________________________________
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
_______________________________________________
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