JohnBasedow
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2014
02:12 AM
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?
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?
3 REPLIES 3
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2014
03:45 AM
Re: Content-type: multipart Possible?
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
and then manually assemble the rest and post it as a body:
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).
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).
JohnBasedow
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2014
05:47 AM
Re: Content-type: multipart Possible?
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)
JohnBasedow
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2014
06:29 AM
Re: Content-type: multipart Possible?
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!
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!