How to send the content type "multipart / related" in ActionScript?

If I want to send the following format in actioncript via http Post:

Content-Type: multipart/related; boundary="END_OF_PART" Content-Length: 423478347 MIME-version: 1.0 Media multipart posting --END_OF_PART Content-Type: application/atom+xml <entry xmlns='http://www.w3.org/2005/Atom'> <title>plz-to-love-realcat.jpg</title> <summary>Real cat wants attention too.</summary> <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo"/> </entry> --END_OF_PART Content-Type: image/jpeg ...binary image data... --END_OF_PART-- 

How can I write ActionScript to send the content type "multipart / related".
Please advise. Thanks.

+1
source share
2 answers

One thing that can help is to use something like the AS3 HTTPClient library - they have helper methods for all kinds of request / response header processing that simple AS3 will not do. You can find it here: http://code.google.com/p/as3httpclientlib/

Doing anything other than a simple HTTP receive / message is always a pain in Flash, and multi-user POST is especially difficult. If this httpclient does not do what you need, let me know and I have another utility that I used in the past. I can dig it out for you, if you need it, just let me know!

Hope this helps, MYK

+1
source

Inspirit MultipartURLLoader will probably help. They did not use it for multipart / related, but it has many useful functions for adding files with different types of content.

For example, you can add files with different types of content using the addFile function:

 addFile(fileContent:ByteArray, fileName:String, dataField:String = 'Filedata', contentType:String = 'application/octet-stream') 

It seems to use multipart / form-data when submitting:

 urlRequest.requestHeaders.push( new URLRequestHeader('Content-type', 'multipart/form-data; boundary=' + getBoundary()) ); 

but you can easily expand it to use multipart / related.

+1
source

Source: https://habr.com/ru/post/1486836/


All Articles