ionic-frameworkionic2ionic-viewionic-popup

Ionic 2 camera usage other than base64 encode


Is there any way to use the camera, but the picture not to be base64 encoded on ionic 2 platform? I want to use other encode than base64.

Thank you


Solution

  • https://ionicframework.com/docs/v2/native/camera/

    Quote from the Ionic docs:

    Choose the format of the return value. Defined in Camera.DestinationType. Default is FILE_URI. DATA_URL : 0, Return image as base64-encoded string, FILE_URI : 1, Return image file URI, NATIVE_URI : 2 Return image native URI (e.g., assets-library:// on iOS or content:// on Android)

    So you now have Camera.DestinationType to equal DATA_URL. If you don't want this you can use FILE_URI which will retrieve the file URI where after that you could use another cordova plugin to actually retrieve the image from the URI so that you can send it to your server

    or

    NATIVE_URI which will return assets-library://..... on iOS and content://..... on Android.

    Which one you need will depend on your use case scenario.