ios - HTTP POST multipart/form-data with setHTTPBody like .csv.gz -
I have to compress a .csv with gzip. To do this:
NSString * limit = @ "*****"; NSString * contentType = [NSString stringWithFormat: @ "Multipart / Form-Data; limit =% @", border]; NSMutableURLRequest * Request = [NSMutableURL request request with url: [NSURL URLWithString: @ "url"]]; [Request [HTTPS: Handle cookies]: No]; [Request timeout interval: 100]; [Set http system: @ "post"]; [AddValue: contentType forHTTPHeaderField: @ "Content Type"]; [Request Set Value: @Headpuffed: @ "Actress-encoding" for "jizip"]; NSMutableData * theBodyData = [NSMutableData data]; [Debotata enddata: [[NSSTING stringwhite format: @ "-% @ \ r \ n", border] Data wrapping encoding: NSUFF 8 string encoding]]; [Debotta Endadata: [@ "Content-Disposal: Form-Data; Name = \" server_value_name \ "\ r \ n \ r \ n" Data Encoding: NSTF 8 string encoding]]; [BodyDataApendData: [CSV string data accessing encoding: NSTF 8 string encoding]]; [The BodyData Appendance: [[NSSTING string with format: @ "\ r \ n -% @ \ r \ n", border] Data wrapping encoding: NSUFF 8 string encoding]]; [The BodyData Appendance: [@ "Content-Disposal: Form-Data; Name = \" File \ "; Filename = \" 99 99 99 99 99 99 99 -D4A 9-A5F2-871-D5 AICGGS \ "\" \ r \ n "Data Using Encoding: NSUFF 8 String Encoding]] [BodyDataApendadata: [@" Content-Type: File / CSV \ r \ n \ r \ n "Data Using Encoding: NSTF 8 String encoding]]; [Bodydata endadata: [CSV string data using encoding: NSUFF 8 string EN Recognition of Lodification: Yes]]; [The BodyData Appendance: [[NSSstring string with format: @ "\ r \ n -% @ - \ r \ n", border] Data wrapping encoding: NSUFF 8 string encoding]]; NSDTA * The BodyDatabase = [The BodyData gzipdata]; [Setup HTTPBD: The BodyDataZip]; NSError * Error = Zero; NSURLResponse * Response = Zero; [NSURLConnectionSynchronousRequest: Response Returning Request: And Response Error: & Error]; The file has been saved to the server but I can not open it ...
Any thoughts?
Thocks for everyone. <
This has worked for me, values in %% only Replace
POST% URI% HTTP / 1.1 Authorization: Original **** X-Host Commune Name:% HOSTNAME% MIME-version: 1.0 Host:% HOST% Content-Length: 523 X - Target - URI:% URI% Content-Type: Multipart / Form-Data; type = "application / vnd.ms-excel"; Start = "& amp; lt; file & gt;"; Range = "- 0246824681357ACXZabcxyz" Connection: Keep-Alive ---- 0246824681357ACXZabcxyz Content Type: Application / vnd.ms-excel; Name = "file" content-transfer-encoding: binary content-id: & lt; File & gt; Content-presentation: form-data; Name = "file"; File name = "usageFile.csv" content-position: file% binary data% ---- 0246824681357ACXZabcxyz--
Comments
Post a Comment