This is a migrated thread and some comments may be shown as answers.

Cordova File API

7 Answers 96 Views
Feedback & Suggestions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Joe
Top achievements
Rank 1
Joe asked on 27 Nov 2013, 03:30 PM
Hi,

I've been working with the File API that is available from Cordova for working with photos and then uploading those images.  I'm running into issues with the FileEntry class and also the FileTransfer class.  Here are some code snippets, I've remarked out the FileTransfer call in this example:

var img = new Image();
img.style.display = 'block';
img.src = "http://localfile/Simulator////C:/Users/me/Pictures/bus.png";

var App = {
        CachedPictures[{ID: 0, ImageBinary: img, ImageNm: "xx", ImageNotes: "xxxx"}],
        SavePicture: function () {
            for (var i = 0; i < App.CachedPictures.length; i++) {
               
                var lastImage = App.CachedPictures[App.CachedPictures.length - 1];
                var url = 'SomeURL?ImageNm=' + encodeURIComponent(lastImage.ImageNm) +
                            '&ImageNotes=' + encodeURIComponent(lastImage.ImageNotes);

                // get instance of file object
                var filePath = lastImage.ImageBinary.src.substr(lastImage.ImageBinary.src.lastIndexOf('///') + 3);
                console.log("filePath:\t" + filePath);
                var file = null;
                window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
                    function (fileSystem) {
                        fileSystem.root.getFile(filePath, { create: true, exclusive: false },
                            function (parent) {
                                console.log(parent);
                            },
                            function () {
                                console.log("** error getting file");
                            });
                    },
                    function (evt) {
                        console.log('** failed in file system request')
                        console.log(evt);
                    });

/*                var imageURI = lastImage.ImageBinary.src;
                var options = new FileUploadOptions();
                options.fileKey = "file";
                options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
                console.log(options.fileName);
                options.mimeType = "text/plain";

                console.log('*** original image source');
                console.log(lastImage.ImageBinary.src);
                console.log('*** modified path');
                console.log(options.fileName);
               

                var ft = new FileTransfer();
                ft.upload(imageURI, url,
                    function (r) {
                        console.log("Code = " + r.responseCode);
                        console.log("Response = " + r.response);
                        console.log("Sent = " + r.bytesSent);
                    },
                    function (error) {
                        // error.code == FileTransferError.ABORT_ERR
                        alert("An error has occurred: Code = " + error.code);
                        console.log("upload error source " + error.source);
                        console.log("upload error target " + error.target);
                    },
                    options);
                ft.abort();*/
            }
        }
}

When trying to use the file FileEntry class i get the following in my console.log call:

filePath: C:/Users/me/Pictures/bus.png App.js:152

** failed in file system request App.js:165

FileError {code: "Not Supported in Simulator"}


Is there a plan in the future to support the Cordova File APIs from the simulator?

Joe

7 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 27 Nov 2013, 04:03 PM
Hello Joe,

As you have found the hard way, Cordova File API is not supported in the Icenium Simulator. We do plan to add support for all core Cordova APIs (now plugins) into the Simulator. File API would be one of the first, with support comming as early as end of January 2014.

Regards,
Steve
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
0
Amir
Top achievements
Rank 1
answered on 13 Dec 2013, 11:45 PM
steve pls
0
Steve
Telerik team
answered on 14 Dec 2013, 09:25 AM
Hi Amir,

As noted in our previous post, the Cordova File API would be added to the Icenium Simulator in the next major version of the product.

Regards,
Steve
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
0
Bala Chandra V
Top achievements
Rank 1
answered on 13 May 2014, 07:48 AM
Is this support Added? I am having more or less same issue?
0
Paul-Henri
Top achievements
Rank 1
answered on 13 May 2014, 05:43 PM
I have the same issue, is there another way to do so?
0
Kaloyan
Telerik team
answered on 15 May 2014, 03:39 PM
Hi,

The support for the Cordova File API is added in the simulator functionality for all of the AppBuilder clients except the In-Browser client. You can check this here. To try it out, you can check our File Sample, which successfully writes, reads and deletes files from your computer. Note, you might need to adjust the Root Folders Location accordingly to your scenario and account permissions.

Further, the simulator (except the one in the In-Browser client) also supports the Cordova FileTransfer API. You will find the sample project for it, here.

I hope this helps. Please, let me know if there is anything more particular that prevents you for using the above APIs and I will be glad to assist you further.

Regards,
Kaloyan
Telerik
 

Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

 
0
jerome
Top achievements
Rank 1
answered on 21 Sep 2014, 02:39 AM
This is a real bugger, I have nearly the same situation I was hoping I could find similar from the wealth factory review
Tags
Feedback & Suggestions
Asked by
Joe
Top achievements
Rank 1
Answers by
Steve
Telerik team
Amir
Top achievements
Rank 1
Bala Chandra V
Top achievements
Rank 1
Paul-Henri
Top achievements
Rank 1
Kaloyan
Telerik team
jerome
Top achievements
Rank 1
Share this question
or