Code Monkey home page Code Monkey logo

cordova-plugin-fileopener's People

Contributors

hellojinjie avatar javacer avatar marob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-fileopener's Issues

Apache Cordova 6.5

Hi, I've upgraded my App to apache cordova 6.5 and now it does not work
This is me config.xml

<!-- Access to all the subdomains on google.com -->
<access origin="http://*.google.com" />    
<access origin="*" launch-external="yes" />

<allow-intent href="http://*/*" />

<allow-intent href="https://*/*" />

<allow-intent href="tel:*" />

<allow-intent href="sms:*" />

<allow-intent href="mailto:*" />

<allow-intent href="geo:*" />

<!-- The above is equivalent to these three declarations -->
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />

<platform name="android">
    <allow-intent href="market:*" />
</platform>

<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>

not able to download file if it contains space in name

i am trying to download pdf file using this plugin
if, for eg. file name doesnt containers space like "file_url.pdf" then it gets downloaded successfully but if there is any space in name of file like "file url.pdf", its gives 404 error

CSV mime type

Can you add a supported mime type for csv files? text/csv

android8.0 open failed

i solved add

<preference name="android-minSdkVersion" value="16" />
<preference name="android-targetSdkVersion" value="23" />

in config.xml

exposed beyond app through Intent.getData()

window.cordova.plugins.FileOpener.openFile("file:///storage/emulated/0/Download/nf.pdf", function(r) {
    console.log("sucesso:", r);
}, function (r) {
    console.log("erro:", r);
});

erro:
file:///storage/emulated/0/Download/nf.pdf exposed beyond app through Intent.getData()

Cannot serve server error messages when trying donwload file

In FileOpener.java missing some like that:

if (status == DownloadManager.STATUS_FAILED)
{
    int reason = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
    String failedReason = "";

    switch(reason){
        case DownloadManager.ERROR_CANNOT_RESUME:
            failedReason = "ERROR_CANNOT_RESUME";
        break;
        case DownloadManager.ERROR_DEVICE_NOT_FOUND:
            failedReason = "ERROR_DEVICE_NOT_FOUND";
        break;
        case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
            failedReason = "ERROR_FILE_ALREADY_EXISTS";
        break;
        case DownloadManager.ERROR_FILE_ERROR:
            failedReason = "ERROR_FILE_ERROR";
        break;
        case DownloadManager.ERROR_HTTP_DATA_ERROR:
            failedReason = "ERROR_HTTP_DATA_ERROR";
        break;
        case DownloadManager.ERROR_INSUFFICIENT_SPACE:
            failedReason = "ERROR_INSUFFICIENT_SPACE";
        break;
        case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
            failedReason = "ERROR_TOO_MANY_REDIRECTS";
        break;
        case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
            failedReason = "ERROR_UNHANDLED_HTTP_CODE";
        break;
        case DownloadManager.ERROR_UNKNOWN:
            failedReason = "ERROR_UNKNOWN";
        break;
        case 400:
            failedReason = "BAD_REQUEST";
        break;  
        case 401:
            failedReason = "UNAUTHORIZED";
        break;
        case 404:
            failedReason = "NOT_FOUND";
        break;  
        case 500:
            failedReason = "INTERNAL_SERVER_ERROR";
        break;                                                                                                                      
    }                        

    JSONObject obj = new JSONObject(); 
    try {                               
        obj.put("message", "Download failed for reason: #" + reason + " " + failedReason);
        callbackContext.error(obj); 
    } catch (JSONException e) {}                            
}

iOS support

Hello, could you please add iOS support?
Thanks.

THREAD WARNING

THREAD WARNING: exec() call to FileOpener.openFile blocked the main thread for 67ms. Plugin should use CordovaInterface.getThreadPool().

Cordova 6.0.0 compatibility

Hi, after cordova update to version 6.0.0 the plugin does not open urls that can be opened from my system, in particular when a jpg file is opened:

I/chromium: [INFO:CONSOLE(312)] "Error in Success callbackId: FileOpener135459028 ReferenceError: url is not defined", source: file:///android_asset/www/cordova.js (312)

before upgrading cordova I had no problems

my code:

   var onSuccess = function(data) {
        alert('message: ' + data.message);
    };


    function onError(error) {
        function alertDismissed() {
            // do something
        }

        navigator.notification.alert(
            error.message,  // message
            alertDismissed,         // callback
            'Attenzione',            // title
            'Ok'                  // buttonName
        );
    }

    var onTrySuccess = function(data) {
        if (data.canBeOpen) {
            window.cordova.plugins.FileOpener.openFile(url, onSuccess, onError);
        }else {
            function alertDismissed() {
                // do something
            }

            navigator.notification.alert(
                'Non è possibile aprire i file con estensione ' + data.extension + '.\nScarica un applicazione in grado di farlo.',  // message
                alertDismissed,         // callback
                'Attenzione',            // title
                'Ok'                  // buttonName
            );
        }
    };

    function onTryError(error) {
        function alertDismissed() {
            // do something
        }

        navigator.notification.alert(
            error.message,  // message
            alertDismissed,         // callback
            'Attenzione',            // title
            'Ok'                  // buttonName
        );
    }


    $('.attachment-list-url').click(function() {
        var url = "http://www.site.it/wp-content/uploads/2015/03/image.jpg"
        alert(url);
        window.cordova.plugins.FileOpener.canOpenFile(url, onTrySuccess, onTryError);
    });

Use for App Update

Hi,

I use fileopener for Auto App Update, the code like that

window.cordova.plugins.FileOpener.openFile(
'http://xxxx/ver1024.apk',
function(){ alert('download now.') },
errorHandler);

But, when I try to call openFile, it always give me open the older version in cache.

May I force download when call openFile each time.

Thank you.
Willow

enhancement

Hi!
Can you add no restriction mime type for downloaded http files or just add .mkv extension?
and possibility to download url with parameters like /file.mkv?pass=3&p=4
getExtension method checked is .mkv?pass=3&p=4 and fail
thx you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.