Ypimagepicker: Get selected image physical url for sending to server?!?!?!?

Created on 28 Aug 2018  路  3Comments  路  Source: Yummypets/YPImagePicker

how to get selected image's physical url for sending to server?!?!?!?

Most helpful comment

@rajabpour, as explained by @gintechsystems you should only need the Data to send the image to the server as follows :

let picker = YPImagePicker()
picker.didFinishPicking { [unowned picker] items, _ in
    if let photo = items.singlePhoto {
        print(photo.image) // Final image selected by the user (UIIMage)
        let imageData = UIImageJPEGRepresentation(photo.image, 1)
        // Typically send imageData to server with a multipart request
    }
    picker.dismiss(animated: true, completion: nil)
}
present(picker, animated: true, completion: nil)

Hope this helps :)

All 3 comments

You don't need the url just get the data.

@rajabpour, as explained by @gintechsystems you should only need the Data to send the image to the server as follows :

let picker = YPImagePicker()
picker.didFinishPicking { [unowned picker] items, _ in
    if let photo = items.singlePhoto {
        print(photo.image) // Final image selected by the user (UIIMage)
        let imageData = UIImageJPEGRepresentation(photo.image, 1)
        // Typically send imageData to server with a multipart request
    }
    picker.dismiss(animated: true, completion: nil)
}
present(picker, animated: true, completion: nil)

Hope this helps :)

@s4cha great example. What are you adding in the next version related to this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

javiermanzo picture javiermanzo  路  6Comments

fukemy picture fukemy  路  6Comments

jonnyarc picture jonnyarc  路  3Comments

VitaliiDeveloper picture VitaliiDeveloper  路  5Comments

uxight picture uxight  路  6Comments