我有一个从相机拍摄的图像。我想上传它的服务器。我从相机下面的代码中获得了图像
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let originalImage = (info[UIImagePickerControllerOriginalImage] as? UIImage)!
imageData = UIImageJPEGRepresentation(originalImage, 100) as NSData?
if Constant.commonfunction.checkFileSize(fileData: imageData!)
{
let data = UploadData()
data.fileName = "image.jpg"
data.fileType = "Image"
data.fileData = imageData as? Data
data.mimeType = "image/jpg"
arr_images.append(data)
picker.dismiss(animated: true, completion: {
self.collectionView.reloadData()
})
}
else
{
Constant.commonfunction.showAlertView(title: "Warning", message: "Please upload a file of size less than 10 MB", vc: self)
}
}
请提出最佳解决方案。