初见

Moya上传带参数的图片

2020-01-05  本文已影响0人  dlxfly

日期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)
上一篇下一篇

猜你喜欢

热点阅读