alamofireimage

Swift - How to save memory using AlamofireImage/ImageShack?

人走茶凉 提交于 2019-11-29 17:31:32
I'm using Alamofire , AlamofireImage to cache images using ImageShack storage with Firebase backend. Sometimes memory comes over 100MB. I want to learn how to improve my image caching and well scaling before uploading. For example I have declared one common cache in class whole project using that AutoPurgingImageCache : let photoCache = AutoPurgingImageCache( memoryCapacity: 100 * 1024 * 1024, preferredMemoryUsageAfterPurge: 60 * 1024 * 1024 ) Is there any way to define these memoryCapacity , preferredMemoryUsageAfterPurge to save memory? What do they mean exactly? I'm using below Alamofire

Download File Using Alamofire 4.0 (Swift 3)

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 05:32:13
问题 In older version of Alamofire. This is how I download file let destinationPath = Alamofire.Request.suggestedDownloadDestination( directory: .documentDirectory, domain: .userDomainMask); Alamofire.download(.GET, urlString, destination: destinationPath) .progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in // print(totalBytesRead) } .response { request, response, _, error in let downloadedFilePath = destinationPath(URL(string: "")!, response!); NSUserDefaultsHelper.saveURL

Alamofire 4.0 Upload MultipartFormData Header

↘锁芯ラ 提交于 2019-11-28 21:18:01
How do we add an authentication header to the upload function of Alamofire 4.0? below is the sample code, however I see no way in adding a header to the function. Alamofire.upload( multipartFormData: { multipartFormData in multipartFormData.append(unicornImageURL, withName: "unicorn") multipartFormData.append(rainbowImageURL, withName: "rainbow") }, to: "https://httpbin.org/post", encodingCompletion: { encodingResult in switch encodingResult { case .success(let upload, _, _): upload.responseJSON { response in debugPrint(response) } case .failure(let encodingError): print(encodingError) } } )

How to upload multiple images in multipart using Alamofire?

六眼飞鱼酱① 提交于 2019-11-28 13:55:17
I am stuck in uploading multiple images in multipart using Alamofire. Can any one help me? Thanks in advance!! For more details, I am using this code to create body part of images data: func imageArrayToNSData(array: [UIImage],boundary:String) -> NSData { let body = NSMutableData() var i = 0; for image in array{ let filename = "image\(i).jpg" let data = UIImageJPEGRepresentation(image,0.8); let mimetype = "image/jpeg" let key = "product_images" body.appendData("--\(boundary)\r\n".dataUsingEncoding(NSUTF8StringEncoding)!) body.appendData("--\(boundary)\r\n".dataUsingEncoding

Swift - How to save memory using AlamofireImage/ImageShack?

半腔热情 提交于 2019-11-28 12:09:13
问题 I'm using Alamofire , AlamofireImage to cache images using ImageShack storage with Firebase backend. Sometimes memory comes over 100MB. I want to learn how to improve my image caching and well scaling before uploading. For example I have declared one common cache in class whole project using that AutoPurgingImageCache : let photoCache = AutoPurgingImageCache( memoryCapacity: 100 * 1024 * 1024, preferredMemoryUsageAfterPurge: 60 * 1024 * 1024 ) Is there any way to define these memoryCapacity ,

Alamofire 4.0 Upload MultipartFormData Header

给你一囗甜甜゛ 提交于 2019-11-27 13:09:10
问题 How do we add an authentication header to the upload function of Alamofire 4.0? below is the sample code, however I see no way in adding a header to the function. Alamofire.upload( multipartFormData: { multipartFormData in multipartFormData.append(unicornImageURL, withName: "unicorn") multipartFormData.append(rainbowImageURL, withName: "rainbow") }, to: "https://httpbin.org/post", encodingCompletion: { encodingResult in switch encodingResult { case .success(let upload, _, _): upload

How to upload multiple images in multipart using Alamofire?

家住魔仙堡 提交于 2019-11-27 07:50:11
问题 I am stuck in uploading multiple images in multipart using Alamofire. Can any one help me? Thanks in advance!! For more details, I am using this code to create body part of images data: func imageArrayToNSData(array: [UIImage],boundary:String) -> NSData { let body = NSMutableData() var i = 0; for image in array{ let filename = "image\(i).jpg" let data = UIImageJPEGRepresentation(image,0.8); let mimetype = "image/jpeg" let key = "product_images" body.appendData("--\(boundary)\r\n"

Downloading UIImage via AlamofireImage? [duplicate]

不问归期 提交于 2019-11-27 05:33:18
This question already has an answer here: How can I get the Data from NSURLSession.sharedSession().dataTaskWithRequest 2 answers I have a URL and want to download the image via a return function, however I cant get it to cooperate properly, here is my func: func getTabImage(url: URL) -> UIImage { Alamofire.request(url) .responseImage { response in if let image = response.result.value { return image } else { print("Failed to get image") } } } I pass in the URL, and want a UIImage returned from the alamofire response. But i get Unexpected non-void return value in void function for the return

Downloading UIImage via AlamofireImage? [duplicate]

雨燕双飞 提交于 2019-11-26 11:37:24
问题 This question already has answers here : How can I get the Data from NSURLSession.sharedSession().dataTaskWithRequest (2 answers) Closed 2 years ago . I have a URL and want to download the image via a return function, however I cant get it to cooperate properly, here is my func: func getTabImage(url: URL) -> UIImage { Alamofire.request(url) .responseImage { response in if let image = response.result.value { return image } else { print(\"Failed to get image\") } } } I pass in the URL, and want