Apache Cordova
  1. Apache Cordova
  2. CB-3185

Exception resolving a Dropbox file from the Gallery

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.0
    • Fix Version/s: None
    • Component/s: Android
    • Labels:
      None

      Description

      The following exception shows in the Logcat:

       
          04-19 10:56:08.360: W/System.err(7926): java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.dropbox.android/files/scratch/Camera%20Uploads/2012-09-09%2011.20.25.jpg: open failed: ENOENT (No such file or directory)
          04-19 10:56:08.390: W/System.err(7926): 	at libcore.io.IoBridge.open(IoBridge.java:416)
          04-19 10:56:08.390: W/System.err(7926): 	at java.io.FileInputStream.<init>(FileInputStream.java:78)
          04-19 10:56:08.390: W/System.err(7926): 	at java.io.FileInputStream.<init>(FileInputStream.java:105)
          04-19 10:56:08.390: W/System.err(7926): 	at org.apache.cordova.FileHelper.getInputStreamFromUriString(FileHelper.java:98)
          04-19 10:56:08.390: W/System.err(7926): 	at org.apache.cordova.CameraLauncher.getScaledBitmap(CameraLauncher.java:582)
          04-19 10:56:08.390: W/System.err(7926): 	at org.apache.cordova.CameraLauncher.onActivityResult(CameraLauncher.java:411)
          04-19 10:56:08.390: W/System.err(7926): 	at org.apache.cordova.DroidGap.onActivityResult(DroidGap.java:864)
          04-19 10:56:08.390: W/System.err(7926): 	at android.app.Activity.dispatchActivityResult(Activity.java:5293)
          04-19 10:56:08.390: W/System.err(7926): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:3315)
          04-19 10:56:08.390: W/System.err(7926): 	at android.app.ActivityThread.handleSendResult(ActivityThread.java:3362)
          04-19 10:56:08.390: W/System.err(7926): 	at android.app.ActivityThread.access$1100(ActivityThread.java:141)
          04-19 10:56:08.390: W/System.err(7926): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
          04-19 10:56:08.390: W/System.err(7926): 	at android.os.Handler.dispatchMessage(Handler.java:99)
          04-19 10:56:08.390: W/System.err(7926): 	at android.os.Looper.loop(Looper.java:137)
          04-19 10:56:08.390: W/System.err(7926): 	at android.app.ActivityThread.main(ActivityThread.java:5041)
          04-19 10:56:08.390: W/System.err(7926): 	at java.lang.reflect.Method.invokeNative(Native Method)
          04-19 10:56:08.390: W/System.err(7926): 	at java.lang.reflect.Method.invoke(Method.java:511)
          04-19 10:56:08.400: W/System.err(7926): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
          04-19 10:56:08.400: W/System.err(7926): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
          04-19 10:56:08.400: W/System.err(7926): 	at dalvik.system.NativeStart.main(Native Method)
          04-19 10:56:08.400: W/System.err(7926): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
          04-19 10:56:08.400: W/System.err(7926): 	at libcore.io.Posix.open(Native Method)
          04-19 10:56:08.400: W/System.err(7926): 	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
          04-19 10:56:08.400: W/System.err(7926): 	at libcore.io.IoBridge.open(IoBridge.java:400)
          04-19 10:56:08.410: W/System.err(7926): 	... 19 more
      

        Activity

        Hide
        Andrew Grieve added a comment -

        Thanks for the report Abel!

        Looks like this is likely due to %20s in the path.
        I think the fix would involve:

        1. Make FileHelper.getRealPath() use a URI, and call .getPath() on it.
        2. Make sure FileHelper.getInputStreamFromUriString() is being called with a file:// prefix (throw an exception if it's not)

        Show
        Andrew Grieve added a comment - Thanks for the report Abel! Looks like this is likely due to %20s in the path. I think the fix would involve: 1. Make FileHelper.getRealPath() use a URI, and call .getPath() on it. 2. Make sure FileHelper.getInputStreamFromUriString() is being called with a file:// prefix (throw an exception if it's not)
        Hide
        Andrew Grieve added a comment -

        Assigned to Ian, since this will almost certainly be fixed with his upcoming File / FileTransfer related changes.

        Show
        Andrew Grieve added a comment - Assigned to Ian, since this will almost certainly be fixed with his upcoming File / FileTransfer related changes.
        Hide
        Pål Jørgensen added a comment -

        The "upcoming File / FileTransfer related changes" you mention; are there another issue describing this?

        I can confirm this problem is present in cordova 2.9.0 aswell.

        Show
        Pål Jørgensen added a comment - The "upcoming File / FileTransfer related changes" you mention; are there another issue describing this? I can confirm this problem is present in cordova 2.9.0 aswell.
        Hide
        Ian Clelland added a comment -

        The File changes are mostly covered by CB-5403. The new File plugin has been released as of last week (v1.0.0)

        I'll try to see if I can reproduce this issue with the new version; I suspect that the same code may run into CB-5975 now, which I believe is caused by a change in Android 4.4 with respect to content provider URLs.

        Show
        Ian Clelland added a comment - The File changes are mostly covered by CB-5403 . The new File plugin has been released as of last week (v1.0.0) I'll try to see if I can reproduce this issue with the new version; I suspect that the same code may run into CB-5975 now, which I believe is caused by a change in Android 4.4 with respect to content provider URLs.
        Hide
        ASF subversion and git services added a comment -

        Commit c56b33035edcfae3327369cb64c4e6818e3d84b4 in branch refs/heads/dev from Ian Clelland
        [ https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-file.git;h=c56b330 ]

        CB-2432 CB-3185 CB-5975: Correctly handle content:// urls especially when non-local-to-device

        Show
        ASF subversion and git services added a comment - Commit c56b33035edcfae3327369cb64c4e6818e3d84b4 in branch refs/heads/dev from Ian Clelland [ https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-file.git;h=c56b330 ] CB-2432 CB-3185 CB-5975 : Correctly handle content:// urls especially when non-local-to-device
        Hide
        Ian Clelland added a comment -

        Abel, can you try this again with the latest release of the File plugin?

        From your original traceback, I believe that the problem with the encoded spaces in the URLs will be solved. However, if DropBox is acting as a content provider, then you might have to try the latest dev branch of File; I've fixed a number of issues with the handling of content:// URLs in the last couple of days.

        Show
        Ian Clelland added a comment - Abel, can you try this again with the latest release of the File plugin? From your original traceback, I believe that the problem with the encoded spaces in the URLs will be solved. However, if DropBox is acting as a content provider, then you might have to try the latest dev branch of File; I've fixed a number of issues with the handling of content:// URLs in the last couple of days.
        Hide
        Ian Clelland added a comment -

        Closing this after 9 months. I can no longer reproduce the original issue. The handling of content:// URLs is correct now, as far as I am aware.

        Show
        Ian Clelland added a comment - Closing this after 9 months. I can no longer reproduce the original issue. The handling of content:// URLs is correct now, as far as I am aware.

          People

          • Assignee:
            Ian Clelland
            Reporter:
            Abel Muiño
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development