In camera function how can I pass both destination type data url and file url in one function

Thread is closed for posting
4 posts, 0 answers
  1. Arun
    Arun avatar
    19 posts
    Member since:
    Jan 2012

    Posted 15 Jun 2013 Link to this post

    In camera function how can I pass both destination type data url and file url in one function

    Following is my code

    function camera() 
, onFail, {
          quality: 50,
          destinationType: Camera.DestinationType.DATA_URL

        function onSuccess(imageData)
          here in imageData I will be getting the image data a i need to get the image uri as well i.e the value obtained from 
       destinationType: Camera.DestinationType.FILE_URL

  2. Steve
    Steve avatar
    10940 posts

    Posted 17 Jun 2013 Link to this post

    Hello Arun, cannot return both DATA_URL and FILE_URI (see Cordova Camera API). If you need to save the picture and have a way to display it as well, use Data URI css technique e.g.:

    url('data:image/png;base64,BASE64_DATA') /* From where you stored you base64 data */

    Make sure to change the content type depending on the MIME type of the image you’re embedding. Additionally make sure to keep the data URI all on one line without line-breaks.


    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  3. Matt
    Matt avatar
    1 posts
    Member since:
    Jan 2014

    Posted 21 Jan 2014 Link to this post


    The problem is you don't get the file name or mime type back on this call.   If you the allow the user to pick any media file, then you don't know if they chose JPEG, MPEG, etc.


    You can't do what you want in one camera call.  As far as I can tell, you have to use FILE_URI first to get the file name and type.  In that callback, then use readAsDataURL with a file reader to get the base64.  It is too bad that DATA_URL doesn't also return the metadata.  

  4. Fernando
    Fernando avatar
    1 posts
    Member since:
    Feb 2016

    Posted 24 Feb 2016 in reply to Matt Link to this post

    Here is a example of how to get file name and base64 image:
Back to Top