cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From László Radics (JIRA) <j...@apache.org>
Subject [jira] [Comment Edited] (CB-10858) Cant access javascript native File function
Date Sun, 05 Jun 2016 05:51:59 GMT

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

László Radics edited comment on CB-10858 at 6/5/16 5:51 AM:
------------------------------------------------------------

here is a workaround
//workaround: https://issues.apache.org/jira/browse/CB-10858
//native API: File([blob], name, properties)
//cordova API: File(name, localURL, type, lastModifiedDate, size)
function fixFile() {
    document.addEventListener("deviceready", function () {
        var cordovaFile = window.File;
        delete window.File;
        var nativeFile = window.File;
        window.File = function () {
            var arg = []; // unshift
            for (var i = arguments.length; i > 0; i--)
                arg[i] = arguments[i - 1];
            if (Array.isArray(arguments[0])) {
                return new (Function.prototype.bind.apply(nativeFile, arg));
            } else {
                return new (Function.prototype.bind.apply(cordovaFile, arg));
            }
        };
    });
}


was (Author: laszlo.radics):
here is a workaround
//workaround: https://issues.apache.org/jira/browse/CB-10858
//native API: File([blob], name, properties)
//cordova API: File(name, localURL, type, lastModifiedDate, size)
function fixFile() {
    document.addEventListener("deviceready", function () {
        var cordovaFile = window.File;
        delete window.File;
        var nativeFile = window.File;
        window.File = function () {
            var arg = []; // unshift
            for (var i = arguments.length; i > 0; i--)
                arg[i] = arguments[i - 1];
            if (Array.isArray(arguments[0])) {
                return new (Function.prototype.bind.apply(nativeFile, arg));
            } else {
                return new (Function.prototype.bind.apply(cordovaFile, arg));
            }
        };
    });
}

> Cant access javascript native File function
> -------------------------------------------
>
>                 Key: CB-10858
>                 URL: https://issues.apache.org/jira/browse/CB-10858
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File
>            Reporter: jose nuno neto
>              Labels: triaged
>
> I am using the cordova-plugin-file and need to create a File object with javascript native
function
> https://developer.mozilla.org/en/docs/Web/API/File
> But this plugin overrides that defenition.
> How can I use the plugin and still have acess to the native File function?



--
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