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

Rahul Pandey commented on CB-9022:
----------------------------------

Hi,

Sorry for the formatting, I have edited the code to remove that checkInImage 
variable and yes it it the cdvfile url image. You can use PhotoLibrary source. 
I mostly tried with that only.

{code:javascript}
function uploadImage(commentImage) {
    var imageUploaded = function(data) {
        console.log("Image Uploaded ", data);
    };

    var ft = new FileTransfer();
    var options = new FileUploadOptions();
    var serverURL = connectUrl + "post/comment";
    options.fileKey = "file";
    if (commentImage.indexOf('jpg') != -1)
        options.fileName = "commentImage.jpg";
    else
        options.fileName = "commentImage.png";
    options.mimeType = "image/jpeg";
    options.chunkedMode = false;
    options.httpMethod = 'POST';
    var headers = { "boundary": "myuploadboundary" } ;
    options.headers = headers;
    var params = {};
    params.access_token = "Access token"
    params.postid = 1;
    params.comment = "This is my comment";
    options.params = params;
    ft.upload(commentImage, encodeURI(serverURL), imageUploaded, function(e) { 
         console.log(JSON.stringify(e)); 
    }, options, true);
}

var onSuccess = function(imgData) {
    //uploadImage(imgData);
    window.resolveLocalFileSystemURL(imgData, function(entry) {
        uploadImage(entry.nativeURL); 
      });
};

var onFail = function(error) { console.log(error); };

var picSourceType = Camera.PictureSourceType.PHOTOLIBRARY;

if (source === 'camera') picSourceType = Camera.PictureSourceType.CAMERA;

var cameraOptions = { 
         quality: 50,
         destinationType: Camera.DestinationType.FILE_URI, 
         sourceType: picSourceType, 
         allowEdit: false, 
         targetWidth: 800, 
         targetHeight: 800, 
         saveToPhotoAlbum: true, 
         encodingType: 0 
 };
navigator.camera.getPicture(onSuccess, onFail, cameraOptions);
{code}


> Cordova Android Filetransfer returning null 
> -"java.lang.IllegalStateException" - "CordovaInterface.getThreadPool()"
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: CB-9022
>                 URL: https://issues.apache.org/jira/browse/CB-9022
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File Transfer
>    Affects Versions: 1.1.0
>         Environment: OS: Mac OS X Yosemite
> Node Version: v0.12.0
> Cordova CLI: 5.0.0
> Xcode version: Xcode 6.3.1 Build version 6D1002 
> ios-sim version: 3.1.1 
> ios-deploy version: 1.4.0 
> android 4.0.0-dev
>            Reporter: Mike Mullins
>            Assignee: Vladimir Kotikov
>              Labels: android, cannot-reproduce, wfc
>
> http://stackoverflow.com/questions/30201674/cordova-android-filetransfer-returning-null
> Attempting to do an android FileTransfer, plugin is working on iOS, i can't 
> seem to get this to go!
> ADB lgocat output:
> E/PluginManager(23753): Uncaught exception from plugin
> E/PluginManager(23753): java.lang.IllegalStateException: Tried to perform an 
> IO operation on the WebCore thread. Use CordovaInterface.getThreadPool() 
> instead.
> FileTransferError
> body: null
> code: null
> exception: null
> http_status: null
> source: null
> target: null
> Trying a file transfer and coming back empty.... 
> Your system information:
> OS: Mac OS X Yosemite
> Node Version: v0.12.0
> Cordova CLI: 5.0.0
> Ionic CLI Version: 1.3.22
> Xcode version: Xcode 6.3.1 Build version 6D1002 
> ios-sim version: 3.1.1 
> ios-deploy version: 1.4.0
> ngCordova upload: http://ngcordova.com/docs/plugins/fileTransfer/
> Running in Crosswalk, not sure that makes any difference.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to