cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ian Clelland (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-7024) Cordova resolveLocalFileSystemURL works but then fileEntry.file() fails
Date Wed, 02 Jul 2014 14:56:24 GMT

    [ https://issues.apache.org/jira/browse/CB-7024?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14049996#comment-14049996
] 

Ian Clelland commented on CB-7024:
----------------------------------

bq. That is stuppid! It's a bug.

The first issue may indeed be a bug; if the permission is missing, and is now required, then
it should be added by the File plugin.

bq. I cannot get the mime-Type for the given fileEntry, so how am I supposed to upload it
via FileTransfer plugin (as it asks explicitely for it - to send it as ContentType to the
server

Calling {{fileEntry.file()}} is supposed to return you a file object, with a mime type, which
you can query like this:

{code}
myFileEntry.file(function(myFile) {
  mimeType = myFile.type;
}, errorHandler);
{code}

If the MIME type is not being attached correctly, or is not being detected properly, then
that is a bug; possibly with our interface to the external content provider.

bq. - that's another stuppid thing, it should detect it if I pass null in the firs place anways).

Having Cordova actually guess the content type is probably not going to happen; there are
too many ways to do it (by extension? by application? by content provider? by actually reading
every file and looking at its structure?), and we have no idea about the cost of getting it
wrong. If you just need *something* for an HTTP header, and you really have no idea what the
data type is, then use {{application/octet-stream}} -- all it says is "this is bytes". You
can always have the server do any required file type detection when the data is uploaded.

Also, how is this a security issue? Is that label appropriate here?

> Cordova resolveLocalFileSystemURL works but then fileEntry.file() fails
> -----------------------------------------------------------------------
>
>                 Key: CB-7024
>                 URL: https://issues.apache.org/jira/browse/CB-7024
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File
>    Affects Versions: 3.0.0, 3.1.0, 3.2.0, 3.3.0, 3.4.0, 3.5.0
>         Environment: Android
>            Reporter: DotNetWise
>            Priority: Blocker
>              Labels: file, mimeType, security
>   Original Estimate: 8m
>  Remaining Estimate: 8m
>
> First, you do a {{navigator.camera.getPicture(uploadPicture_step1, uploadError, chooseOptions);}}
> with success and then you do {{window.resolveLocalFileSystemURL(fileURI, function (fileEntry)
{}}
> again with success.
> Now if you call that {{fileEntry.file(function(info) {}, function(err) { }); }}you always
get an exception and the error callback is called with {{err.code = 1000}};
> The error in {{logcat}} is missing {{android.permission.MANAGE_DOCUMENTS}}
> That is stuppid! It's a bug.
> I cannot get the mime-Type for the given fileEntry, so how am I supposed to upload it
via FileTransfer plugin (as it asks explicitely for it - to send it as ContentType to the
server - that's another stuppid thing, it should detect it if I pass null in the firs place
anways).
> This issue is for the files that are comming from custom providers such as "downloads".
e.g. 
> {{content://document/primary%3ADownload/11june.pdf}}
> In config.xml I do have 
> {{<preference name="AndroidPersistentFileLocation" value="Compatibility" />
>   <preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,root"
/>
> <feature name="File">
>     <param name="android-package" value="org.apache.cordova.file.FileUtils" />
>     <param name="onload" value="true" />
>   </feature>
>   <feature name="FileTransfer">
>     <param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer"
/>
>   </feature>
> <feature name="Camera">
>     <param name="android-package" value="org.apache.cordova.camera.CameraLauncher"
/>
>   </feature>}}
> In {{AndroidManifest.xml}} I do have 
> {{<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
>   }}  
> Here are some logs
> {{
> E/DatabaseUtils(24425): java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider
uri conten
> nts/document/primary%3ADownload/11june.pdf from pid=22853, uid=10197 requires android.permission.MANAGE_DOCUMENTS,
or grantUriPermission()
> E/DatabaseUtils(24425):         at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:467)
> E/DatabaseUtils(24425):         at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:394)
> E/DatabaseUtils(24425):         at android.content.ContentProvider$Transport.query(ContentProvider.java:194)
> E/DatabaseUtils(24425):         at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
> E/DatabaseUtils(24425):         at android.os.Binder.execTransact(Binder.java:404)
> E/DatabaseUtils(24425):         at dalvik.system.NativeStart.run(Native Method)
> W/System.err(22853): java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider
uri content:/
> /document/primary%3ADownload/11june.pdf from pid=22853, uid=10197 requires android.permission.MANAGE_DOCUMENTS,
or grantUriPermission()
> W/System.err(22853):    at android.os.Parcel.readException(Parcel.java:1465)
> W/System.err(22853):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
> W/System.err(22853):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
> W/System.err(22853):    at android.content.ContentProviderProxy.query(ContentProviderNative.java:413)
> W/System.err(22853):    at android.content.ContentResolver.query(ContentResolver.java:461)
> W/System.err(22853):    at android.content.ContentResolver.query(ContentResolver.java:404)
> W/System.err(22853):    at org.apache.cordova.file.ContentFilesystem.openCursorForURL(ContentFilesystem.java:258)
> W/System.err(22853):    at org.apache.cordova.file.ContentFilesystem.getFileMetadataForLocalURL(ContentFilesystem.java:169)
> W/System.err(22853):    at org.apache.cordova.file.FileUtils.getFileMetadata(FileUtils.java:811)
> W/System.err(22853):    at org.apache.cordova.file.FileUtils.access$400(FileUtils.java:52)
> W/System.err(22853):    at org.apache.cordova.file.FileUtils$14.run(FileUtils.java:383)
> W/System.err(22853):    at org.apache.cordova.file.FileUtils$24.run(FileUtils.java:540)
> W/System.err(22853):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
> W/System.err(22853):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
> W/System.err(22853):    at java.lang.Thread.run(Thread.java:841)
> }}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message