alamofire

Alamofire 4 upload with parameters

有些话、适合烂在心里 提交于 2019-11-26 09:11:39
问题 I\'m doing the below to upload a PNG file with parameters: Alamofire.upload( multipartFormData: { multipartFormData in multipartFormData.append(UIImagePNGRepresentation(tempImage!)!, withName: \"file\", fileName: \"picture.png\", mimeType: \"image/png\") // Send parameters multipartFormData.append((UserDefaults.standard.value(forKey: Email) as! String).data(using: .utf8)!, withName: \"email\") multipartFormData.append(\"png\".data(using: .utf8)!, withName: \"type\") }, to: \"user/picture\",

NSURLSession concurrent requests with Alamofire

和自甴很熟 提交于 2019-11-26 08:51:48
问题 I\'m experiencing some strange behaviour with my test app. I\'ve about 50 simultaneous GET requests that I send to the same server. The server is an embedded server on a small piece of hardware with very limited resources. In order to optimize the performance for each single request, I configure one instance of Alamofire.Manager as follows: let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() configuration.HTTPMaximumConnectionsPerHost = 2 configuration

Sending json array via Alamofire

六眼飞鱼酱① 提交于 2019-11-26 08:50:43
问题 I wonder if it\'s possible to directly send an array (not wrapped in a dictionary) in a POST request. Apparently the parameters parameter should get a map of: [String: AnyObject]? But I want to be able to send the following example json: [ \"06786984572365\", \"06644857247565\", \"06649998782227\" ] 回答1: You can just encode the JSON with NSJSONSerialization and then build the NSURLRequest yourself. For example, in Swift 3: var request = URLRequest(url: url) request.httpMethod = "POST" request

Alamofire invalid value around character 0

谁说我不能喝 提交于 2019-11-26 08:13:42
问题 Alamofire.request(.GET, \"url\").authenticate(user: \"\", password: \"\").responseJSON() { (request, response, json, error) in println(error) println(json) } This is my request with Alamofire, for a certain request it sometime works, but sometimes i get: Optional(Error Domain=NSCocoaErrorDomain Code=3840 \"The operation couldn’t be completed. (Cocoa error 3840.)\" (Invalid value around character 0.) UserInfo=0x78e74b80 {NSDebugDescription=Invalid value around character 0.}) I\'ve read that

IPv6 App Store Rejection

不羁的心 提交于 2019-11-26 07:20:28
问题 Our update has been rejected twice today for ipv6 network connectivity issues. Our networking code has not changed between the previous release and this current release. The app only makes https network requests to api.metooapp.io, which is correctly configured for ipv6 [0] and runs behind route53 on AWS. There are no hard-coded IP addresses in the code. I am unable to reproduce this issue, even after following the steps to create an ipv6 network at [1] which is the link that was provided in

Chain multiple Alamofire requests

孤人 提交于 2019-11-26 06:17:08
问题 I\'m looking for a good pattern with which I can chain multiple HTTP requests. I want to use Swift, and preferrably Alamofire. Say, for example, I want to do the following: Make a PUT request Make a GET request Reload table with data It seems that the concept of promises may be a good fit for this. PromiseKit could be a good option if I could do something like this: NSURLConnection.promise( Alamofire.request( Router.Put(url: \"http://httbin.org/put\") ) ).then { (request, response, data,

upload image to server using Alamofire

两盒软妹~` 提交于 2019-11-26 05:29:20
问题 this is my code that I want to upload image to server using Alamofire, it not error but it can\'t push image to server. what should I do ? Thank in advance. let url = URL(string: urlString)! var urlRequest = URLRequest(url: url) urlRequest.httpMethod = \"POST\" let parameters = [\"name\": rname] do { urlRequest.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: []) } catch { print(error) } urlRequest.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")

Cannot install Alamofire in new Xcode Project. “No Such module Alamofire”

*爱你&永不变心* 提交于 2019-11-26 04:46:46
问题 I follow the instructions to the T. Fresh install of all, yet getting the error: \"No Such module Alamofire\" Directions here: In the meantime, you can simply add Alamofire as a git submodule, drag the Alamofire.xcodeproj file into your Xcode project, and add the framework product as a dependency for your application target. And my screenshots 回答1: Make sure you haven't added any files from Alamofire to your project except for the Alamofire.xcodeproj Here is step by step instruction: Download

Alamofire Swift 3.0 Extra argument in call

谁说胖子不能爱 提交于 2019-11-26 04:20:30
问题 I have migrated my project to Swift 3 (and updated Alamofire to latest Swift 3 version with pod \'Alamofire\', \'~> 4.0\' in the Podfile). I now get an \"Extra argument in call\" error on every Alamofire.request. Eg: let patientIdUrl = baseUrl + nextPatientIdUrl Alamofire.request(.POST, patientIdUrl, parameters: nil, headers: nil, encoding: .JSON) Can anybody tell me why ? 回答1: According to Alamofire documentation for version 4.0.0 URL request with HTTP method would be followings: Alamofire

AlamoFire GET api request not working as expected

穿精又带淫゛_ 提交于 2019-11-26 03:19:02
问题 I am trying to get learn how to use AlamoFire and I am having trouble. My method so far is as follows: func siteInfo()->String?{ var info:NSDictionary! var str:String! Alamofire.request(.GET, MY_API_END_POINT).responseJSON {(request, response, JSON, error) in info = JSON as NSDictionary str = info[\"access_key\"] as String //return str } return str } This returns nil which is a problem. From what I have read here, this is because the request can take a while so the closure doesn\'t execute