Moya上传带参数的图片

日期2020.1.5

let formatter = DateFormatter()
formatter.dateFormat = "yyyyMMddHHmmss"
let fileName = "\(formatter.string(from: Date()))"+".png"
let formData = MultipartFormData(provider: .data(Data), name: "pic",fileName: fileName, mimeType: "image/png")
//主要是这一步把value 转成Data格式
let formData2 = MultipartFormData(provider: .data("value".data(using: String.Encoding.utf8)!), name: "key")
let multipartData = [formData, formData2]
return .uploadMultipart(multipartData)

你可能感兴趣的:(Moya上传带参数的图片)