I have picked image from image picker and then reduced it's size to below 1 MB and then trying to upload with below function implementation but it was not successful.
Request body schema should be as mentioned in the above image.
please suggest proper way of uploading image with mentioned request body schema.
//Method for uploading image
func uploadImageFile(url:String, imageData: Data, fileName: String, completion: @escaping (Bool) -> Void) {
let headers = configureImageCurrentSession()
AF.upload(
multipartFormData: { multipartFormData in
multipartFormData.append(imageData, withName: fileName)
},
to: url, method: .put , headers: headers)
.response { resp in
print(resp)
print("Data::: \(String(data: resp.data ?? Data(), encoding: .utf8))")
completion(true)
}
}
According to the request body schema need to pass content as object required one how to include that as well in the request.
In completion response it prints as like this.
Data::: Optional("{"statusCode":400,"error":"Bad Request","message":"part content is missing"}")