Content-type: multipart Possible?

I’m trying to figure out how to add multipart headers for a multipart form-data form using a roUrlTransfer object.

The problem is that you need to separate each of the “parts” with a boundary, and the requisite newlines need to be there between sections. If I try to fudge these headers by adding the newlines myself, the header gets rejected, and doesn’t make it to the server.

Is there any way to build a multipart header, without implementing this myself?

Based on skimming this http://www.w3.org/TR/html401/interact/f … -17.13.4.2 , I think you should add this header to roUrlTransfer

Content-Type: multipart/form-data; boundary=AaB03x

and then manually assemble the rest and post it as a body:

--AaB03x
Content-Disposition: form-data; name="submit-name"

Larry
--AaB03x
Content-Disposition: form-data; name="files"; filename="file1.txt"
Content-Type: text/plain

... contents of file1.txt ...
--AaB03x--

I am not clear on how were you fudging but the way i understand it, there is no “multipart header” - instead is a multipart request (with a single header).

Your response makes sense – any clue how to mix ASCII and byte data when building the body? (As far as the Roku API is concerned)

Awesome – thanks for your clarification!

I was able to accomplish this by creating the body like you mentioned in a String then loading it into an roByteArray, and writing it to a temp file
Then I load my binary file into an roByteArray and use AppendFile to append the contents to the first file
I then append the final boundary String bytes (Boundary + “–” + Chr(13) + Chr(10) + Chr(13) + Chr(10)) to that same file

The final step is to use AsyncPostFromFile with that temporary file.

Thanks again!