简体   繁体   中英

ASIFormDataRequest: POST both image/jpeg and application/xml with a

Given both:

NSData *jpegData;
NSString *xmlPost:

How do I construct an ASIFormDataRequest to post both the image/jpeg data and the applicaton/xml data as a multipart/mixed POST request?

I'm afraid that I'm not actually answering about your question.

Two facts.

  1. The ASIFormDataRequest class is not designed to support 'multipart/mixed'. (at least, currently)
  2. XML is just a plain string which can be sent via multipart/form-data too.

If your situation is forcing you have to use multipart/mixed , just ignore me. (for instance, your client don't want to modifying server program which support only multipart/mixed .)

If not, please think again once. Do you really need the multipart/mixed itself? No choice? Never 'multipart/form-data'? As I know, most server part programmers like 'multipart/form-data' more than other rarely used format because it supported by most server frameworks. So it makes their life a lot easier :)

If you really want another 'regularity' or 'efficiency' or some other specials instead of simplicity, you should consider other than HTTP. The only benefits of HTTP is stability and compatibility. (from it's well-defined specification and long history) This is most important benefits, but may not suitable for you.

I didn't try 'multipart/mixed'. Maybe it's possible someone has a simple way to do this. But basically this is a kind of hacking job. (enabling feature which absent on original design) This should be painful. It'll be easier making your own class from the HTTP specification.

I strongly recommend you to use multipart/form-data instead of. Which is supported on the class by design. You can assume an XML source just like a plain string. Which can be sent via plain POST field value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM