Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-8235

phonegap plugin getpicture method fails on android when filename has spaces

VotersWatch issueWatchersLinkUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.5.0
    • None
    • None
    • android

    Description

      My version of the phonegap camera plugin is 0.3.4 and phonegap cli of 4.1.2-0.22.10, android phonegap platform version is 3.6.4, build version 3.5.0 in config.xml, testing on Android 4.x, below is my code snippet for getting images from Samsung phone from either gallery or dropbox:

      navigator.camera.getPicture(
      uploadPhoto,
      function(message)
      {
      console.log("Get Picture Failed:"+ message);
      }
      ,
      {
      quality: 50,
      allowEdit:false,
      correctOrientation: true,
      targetWidth: 800,
      destinationType: navigator.camera.DestinationType.FILE_URI,
      sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
      }
      );

      when i choose an image from the gallery it always takes the native_uri (content:// )rather than the file_uri (FILE:///), irrespective of the destination type chosen. But when the app tries to access an image via dropbox the returned uri is always file_uri irrespective of the destination type chosen. Now,

      -If the filename does not have a space in it like 'Photo7.jpg' then it works fine for all cases.
      -If the file name does have space in it like 'Photo 7 new.jpg' then it works fine if it resides in the gallery since the native_uri is always used and it eliminates the space. Please note that the file_uri still contains space in the filename but is not being used by the getpicture method.
      -Now the issue comes in when the app tries to access the same image 'Photo 7 new.jpg' via dropbox. In this case the returned uri is always file_uri and contains spaces. This fails the getpicture method of the camera api and executes failure callback with message "Get Picture Failed:Unable to create bitmap!"

      Is there any way to accomodate space by tweaking phonegap/cordova code? Else is there any workaround to encode_uri or anything else? Thanks for any help!

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            diwas2020 diwas
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment