this is my ios API call function
func Attachment() {
if let image = selectedImage {
if let imageData = image.jpegData(compressionQuality: 0.5) {
let fileItem = Ktor_httpPartData.FileItem(data: imageData, name: "image.jpg", mimeType: "image/jpeg")
ApiUseCase().Attachment(ticket_id: ticket_no!, breakdown_image: fileItem) { response, error in
// Your completion handler code here
DispatchQueue.main.async {
if let error = error {
// Handle the error case here
print("Error: \(error.localizedDescription)")
} else if let response = response {
if response[0].iserror == false {
// Handle the success case here
print("Image uploaded successfully")
} else {
// Handle the case where the API response indicates an error
print("API returned an error")
}
}
}
}
}
}
}