Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Android, CordovaJS, iOS
    • Labels:
      None

      Description

      It would be useful to add the ability to access files directly from a device's photo/video library. To do this, support for native URIs is necessary—for instance, iOS's assets-library:// scheme.

        Activity

        Hide
        Max Woghiren added a comment -

        I've submitted a preliminary pull request here: https://github.com/apache/cordova-ios/pull/6

        Show
        Max Woghiren added a comment - I've submitted a preliminary pull request here: https://github.com/apache/cordova-ios/pull/6
        Hide
        Joe Bowser added a comment -

        On Android, the File System is where the pictures are stored, and we already have access to the SD Card. In addition, we already have access to both the assets directory and the resources directory on Android, so I'm not sure how Android would be affected by this.

        Show
        Joe Bowser added a comment - On Android, the File System is where the pictures are stored, and we already have access to the SD Card. In addition, we already have access to both the assets directory and the resources directory on Android, so I'm not sure how Android would be affected by this.
        Hide
        Max Woghiren added a comment -

        On Android, when Camera.getPicture is called with DestinationType.NATIVE_URI, it might be fine to just act as though FILE_URI were passed.

        Show
        Max Woghiren added a comment - On Android, when Camera.getPicture is called with DestinationType.NATIVE_URI, it might be fine to just act as though FILE_URI were passed.
        Hide
        Max Woghiren added a comment -

        Also, Joe, this was assigned to you by default—I don't have a way to change assignee. Sorry about that! Feel free to reassign to me. (I had Andrew Grieve try to do it, but there's apparently some access level neither of us has in order to do that. If you have a moment to give me the ability to do that sort of thing, I'd really appreciate it!)

        Show
        Max Woghiren added a comment - Also, Joe, this was assigned to you by default—I don't have a way to change assignee. Sorry about that! Feel free to reassign to me. (I had Andrew Grieve try to do it, but there's apparently some access level neither of us has in order to do that. If you have a moment to give me the ability to do that sort of thing, I'd really appreciate it!)
        Hide
        Max Woghiren added a comment -

        Never mind—Fil gave me access. Thanks Fil!

        Show
        Max Woghiren added a comment - Never mind—Fil gave me access. Thanks Fil!
        Hide
        Andrew Grieve added a comment -

        Joe - Wouldn't this map to content:// URIs on Android? Or do we have the ability to convert from content:// to file:// URLs? Never really worked with them on Android...

        Show
        Andrew Grieve added a comment - Joe - Wouldn't this map to content:// URIs on Android? Or do we have the ability to convert from content:// to file:// URLs? Never really worked with them on Android...
        Hide
        Simon MacDonald added a comment -

        Andrew Grieve I added some code to window.resolveLocalFileSystemURI so that it can handle most content:// uri's and return a file:// path. It is useful when taking a picture and then manipulating the file via the File API.

        Show
        Simon MacDonald added a comment - Andrew Grieve I added some code to window.resolveLocalFileSystemURI so that it can handle most content:// uri's and return a file:// path. It is useful when taking a picture and then manipulating the file via the File API.
        Hide
        Max Woghiren added a comment -

        New pull request, adding the new destination type to CameraConstants.js: https://github.com/apache/cordova-js/pull/5

        Show
        Max Woghiren added a comment - New pull request, adding the new destination type to CameraConstants.js: https://github.com/apache/cordova-js/pull/5
        Hide
        Max Woghiren added a comment -

        New pull request, adding a manual test. https://github.com/apache/cordova-mobile-spec/pull/1

        Show
        Max Woghiren added a comment - New pull request, adding a manual test. https://github.com/apache/cordova-mobile-spec/pull/1
        Hide
        Max Woghiren added a comment -

        Those last two pull requests have been merged, so here's the final piece of the puzzle for one method (FileEntry.file()):

        https://github.com/apache/cordova-ios/pull/7

        Show
        Max Woghiren added a comment - Those last two pull requests have been merged, so here's the final piece of the puzzle for one method (FileEntry.file()): https://github.com/apache/cordova-ios/pull/7
        Hide
        Max Woghiren added a comment -
        Show
        Max Woghiren added a comment - Some implementations: https://github.com/apache/cordova-ios/pull/8 and corresponding tests: https://github.com/apache/cordova-mobile-spec/pull/2
        Hide
        Max Woghiren added a comment -

        The above two pull requests are about ready to go. Please take a look when you have a moment!

        Show
        Max Woghiren added a comment - The above two pull requests are about ready to go. Please take a look when you have a moment!
        Show
        Andrew Grieve added a comment - Pull requests merged! last iOS commit: https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=commit;h=6e19115dda861abdaf62a3d660c58c75b32bb03d last Mobile-spec commit: https://git-wip-us.apache.org/repos/asf?p=cordova-mobile-spec.git;a=commit;h=94d1c00e1ec747703fff52f0ce5581475ac6d72f Android commit: https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=commit;h=1246a81d391252dff78544d5908287a20b41a7dd You can now close the pull requests.
        Hide
        Andrew Grieve added a comment -

        BTW - when testing this out on my phone, the mobile-spec test did not work when I selected an image from a picasa album. Getting this to work should probably be a part of the this bug.

        Show
        Andrew Grieve added a comment - BTW - when testing this out on my phone, the mobile-spec test did not work when I selected an image from a picasa album. Getting this to work should probably be a part of the this bug.
        Hide
        Max Woghiren added a comment -

        Did all of the tests fail? I'll check it out tomorrow.

        Show
        Max Woghiren added a comment - Did all of the tests fail? I'll check it out tomorrow.
        Hide
        Max Woghiren added a comment - - edited

        Here's the situation:

        Picking a file from Picasa works on my Galaxy S2 running Android 4.0.3. Doing so copies the image locally and works with that.

        Picking a file from Picasa does not work on Andrew's Nexus 4 running Android 4.2.2. The Intent passed to CameraLauncher.onActivityResult contains a "NOT CACHED" URI and appears to be unusable.

        However, when the Intent is being created in CameraLauncher.getImage, it is given an "image/*" type. Changing this to "*/*" provides a content URI, which is nice, but it's of the form "content://com.google.android.gallery3d.provider/picasa/item/...", which isn't usable in the usual way; FileUtils.getRealPathFromURI returns null. This case probably just needs to be handled using ContentResolver.openInputStream, which would require some FileUtils refactoring.

        One more note: Picasa photos don't appear to work with the existing FILE_URI DestinationType or <input type="file" /> picker, so this issue probably belongs in its own bug.

        Show
        Max Woghiren added a comment - - edited Here's the situation: Picking a file from Picasa works on my Galaxy S2 running Android 4.0.3. Doing so copies the image locally and works with that. Picking a file from Picasa does not work on Andrew's Nexus 4 running Android 4.2.2. The Intent passed to CameraLauncher.onActivityResult contains a "NOT CACHED" URI and appears to be unusable. However, when the Intent is being created in CameraLauncher.getImage, it is given an "image/*" type. Changing this to "*/*" provides a content URI, which is nice, but it's of the form "content://com.google.android.gallery3d.provider/picasa/item/...", which isn't usable in the usual way; FileUtils.getRealPathFromURI returns null. This case probably just needs to be handled using ContentResolver.openInputStream, which would require some FileUtils refactoring. One more note: Picasa photos don't appear to work with the existing FILE_URI DestinationType or <input type="file" /> picker, so this issue probably belongs in its own bug.
        Hide
        Joe Bowser added a comment -

        Can we close this? Or is there something missing from CB-3186

        Show
        Joe Bowser added a comment - Can we close this? Or is there something missing from CB-3186

          People

          • Assignee:
            Max Woghiren
            Reporter:
            Max Woghiren
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development