How Can I post An Array of Pictures With Following Method Here

ぃ、小莉子 提交于 2019-12-13 03:54:53

问题


I am Using Swift 3 and want to post an Array of pictures with this method - please help how can I do that

if let imageData = UIImageJPEGRepresentation(customKindImage.image! , 1) {
  print("There is Not Any Images to upload!")

  let uploadScriptUrl = URL(string : "http://www.swiftdeveloperblog.com/http-post-example-script/")
  var request = URLRequest(url: uploadScriptUrl!)
  request.httpMethod = "POST"
  request.setValue("Keep-Alive" , forHTTPHeaderField : "Connection")

  let task = URLSession.shared.uploadTask(with: request, from: imageData, completionHandler: { (data, response, error) in
      guard let _ = data, error == nil else {
          print(error?.localizedDescription ?? "Error")
          return
      }
      //access data here
  })            
  task.resume()
}

and here is my Array

var photoes : [UIImage] = [
    UIImage(named: "1.jpg")!,
    UIImage(named: "2.jpg")!,
    UIImage(named: "3.jpg")!]

来源:https://stackoverflow.com/questions/43952631/how-can-i-post-an-array-of-pictures-with-following-method-here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!