Ios 使用Alamofire在url中发布base64字符串

Ios 使用Alamofire在url中发布base64字符串,ios,swift,alamofire,Ios,Swift,Alamofire,我正在尝试将一些图像发布到服务器,这些图像是用base64字符串编码的。我使用Alamofire发布图像,在我的例子中,我的post方法中没有参数,所有的都在url中。 以下是我如何将图像编码为base64字符串: let imageData:NSData = UIImagePNGRepresentation(data)! as NSData let strBase64:String = imageData.base64EncodedString(options: .lineLength64Ch

我正在尝试将一些图像发布到服务器,这些图像是用base64字符串编码的。我使用Alamofire发布图像,在我的例子中,我的post方法中没有参数,所有的都在url中。 以下是我如何将图像编码为base64字符串:

let imageData:NSData = UIImagePNGRepresentation(data)! as NSData
let strBase64:String = imageData.base64EncodedString(options: .lineLength64Characters)
self.pictures[1] = strBase64
下面是我的alamofire用法:

let header : HTTPHeaders = [
        "Content-Type": "application/x-www-form-urlencoded"
    ]
url = "myUrl"
Alamofire.request(url.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)! , method: .post, encoding: URLEncoding(destination: .methodDependent) , headers : header)
服务器上的服务是
FormUrlEncoded
类型。如何发送图像,我使用swift作为编程语言