optimise
This commit is contained in:
@@ -58,6 +58,16 @@ extension DDAlamofire {
|
||||
}
|
||||
}
|
||||
|
||||
public func upload<T:Decodable>(urlString:String,headers:HTTPHeaders? = nil,responseType:T.Type = T.self,multipartFormData: @escaping (MultipartFormData) -> Void,uploadProgress: @escaping (Progress) -> Void) -> Single<T?> {
|
||||
return Single<T?>.create {[weak self] single in
|
||||
self?.upload(urlString: urlString,method: .post,headers: headers,responseType: responseType,multipartFormData: multipartFormData,uploadProgress: uploadProgress,completionHandler: { response in
|
||||
self?.logInfo(parameters: nil, response: response)
|
||||
single(.success(response.value))
|
||||
})
|
||||
return Disposables.create()
|
||||
}
|
||||
}
|
||||
|
||||
private func logInfo<T:Decodable,P:Encodable>(parameters:P?,response:AFDataResponse<T>) {
|
||||
DDLog(message: (parameters.debugDescription+"\n"+response.debugDescription))
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ open class DDAlamofire : NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
public func upload<T: Decodable,P: Encodable>(urlString:String,method:HTTPMethod,parameters:P? = nil,encoding:ParameterEncoder = URLEncodedFormParameterEncoder.default,headers:HTTPHeaders? = nil,responseType:T.Type = T.self,multipartFormData: @escaping (MultipartFormData) -> Void,uploadProgress: @escaping (Progress) -> Void,completionHandler: @escaping ((AFDataResponse<T>) -> Void)) {
|
||||
public func upload<T: Decodable>(urlString:String,method:HTTPMethod,headers:HTTPHeaders? = nil,responseType:T.Type = T.self,multipartFormData: @escaping (MultipartFormData) -> Void,uploadProgress: @escaping (Progress) -> Void,completionHandler: @escaping ((AFDataResponse<T>) -> Void)) {
|
||||
let _ = AF.upload(multipartFormData: { muiltipart in
|
||||
multipartFormData(muiltipart)
|
||||
}, urlString: urlString,method: method,headers: headers,requestModifier: {$0.timeoutInterval = 15},uploadProgress: { progress in
|
||||
|
||||
Reference in New Issue
Block a user