-2

I have a captured image from camera.I want to upload it server.I have got image from camera from below code

 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)
    }



  }

Please suggest the best solution.

TechChain
  • 8,404
  • 29
  • 103
  • 228

1 Answers1

0

I was also having same issue but in objective C. hope this can help you.

check this file of objective C

UIImage+Resize.h

UIImage+Resize.m