cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Ruß (JIRA) <j...@apache.org>
Subject [jira] [Comment Edited] (CB-7270) Cordova 3.5.0-0.2.4
Date Fri, 18 Sep 2015 10:51:04 GMT

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

Aaron Ruß edited comment on CB-7270 at 9/18/15 10:50 AM:
---------------------------------------------------------

I am not sure if that is the same problem, but in a plugin I wrote, I had a similar thing
that a URI starting with protocol {{content:}} could not be uploaded via Cordova's file-tranfer
plugin.

I suspect this might be due to the {{content}} protocol URI that file-transfer cannot handle
( ? )

I solved it base on a example code from
http://stackoverflow.com/a/18707044/4278324

basically the {{content:}} gets resolved to a {{file:}} URI that can then be uploaded (maybe
"resolving" {{content:}} URIs should be added to the Android file-transfer and file-system
plugins?)

{code:title=code snippet for resolving content URIs|borderStyle=solid}
//input: URI imageUri
//uses: CordovaPlugin.cordova.getActivity() -> activity
String [] proj={MediaStore.Images.Media.DATA};
Cursor cursor = activity.getContentResolver().query(imageUri,
  proj,	// Which columns to return
  null,	// WHERE clause; which rows to return (all rows)
  null,	// WHERE clause selection arguments (none)
  null);	// Order-by clause (ascending by name)
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();

String path = cursor.getString(column_index);
Log.d(TAG, "file path: " + path);
            
File imgFile = new File(path);
Log.d(TAG, "file size = " + imgFile.length());

imageUri = Uri.fromFile(path);
Log.d(TAG, "resolved URI " + imageUri);
{code}


was (Author: russa):
I am not sure if that is the same problem, but in a plugin I wrote, I had a similar thing
that a URI starting with protocol {{content:}} could not be uploaded via Cordova's file-tranfer
plugin.

I suspect this might be due to the {{content}} protocol URI that file-transfer cannot handle(?)

I solved it base on a example code from
http://stackoverflow.com/a/18707044/4278324

basically the {{content:}} gets resolved to a {{file:}} URI that can then be uploaded (maybe
"resolving" {{content:}} URIs should be added to the Android file-transfer and file-system
plugins?)

{code:title=code snippet for resolving content URIs|borderStyle=solid}
//input: URI imageUri
//uses: CordovaPlugin.cordova.getActivity() -> activity
String [] proj={MediaStore.Images.Media.DATA};
Cursor cursor = activity.getContentResolver().query(imageUri,
  proj,	// Which columns to return
  null,	// WHERE clause; which rows to return (all rows)
  null,	// WHERE clause selection arguments (none)
  null);	// Order-by clause (ascending by name)
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();

String path = cursor.getString(column_index);
Log.d(TAG, "file path: " + path);
            
File imgFile = new File(path);
Log.d(TAG, "file size = " + imgFile.length());

imageUri = Uri.fromFile(path);
Log.d(TAG, "resolved URI " + imageUri);
{code}

> Cordova 3.5.0-0.2.4
> -------------------
>
>                 Key: CB-7270
>                 URL: https://issues.apache.org/jira/browse/CB-7270
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Camera, Plugin File Transfer
>    Affects Versions: 3.5.0
>         Environment: Android
>            Reporter: Mitesh
>
> I am using the the camera plugin:
> Below is the code to demonstrate what I am trying to achieve:
> pictureSource=navigator.camera.PictureSourceType;
> destinationType=navigator.camera.DestinationType;
>     
>     navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, 
>       destinationType: destinationType.FILE_URI,
>       sourceType: pictureSource.PHOTOLIBRARY });
> function onPhotoURISuccess(imageURI) {
> alert(imageURI);
> // returns 'content:///123456'
> window.resolveLocalFileSystemURL(imageURI, function(fileEntry){
>   alert(fileEntry.toURL());
>   file_url = fileEntry.toURL();
>   // returns 'file:///image.jpg'
>    var options = new FileUploadOptions();
>    options.fileKey = "file";
>    options.fileName =     file_url.substr(file_url.lastIndexOf('/') + 1);
>    // but the file transfer is not working, as the file uri is not in the formate of
cdvfile://image.jpg as specified in the file transfer doc.
>    var ft = new FileTransfer();
>    ft.upload($scope.file_url, encodeURI(server_url), win, fail, options);
> })
> }
> Camera image selector on success it is returning the wrong file url, please let me know
how to fix this.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message