简体   繁体   English

如何在 Inappbrowser Cordova 上将下载或响应作为文件处理

[英]How to Handle Download or Response as File on Inappbrowser Cordova

伙计们,帮我处理我的 Cordova 应用程序上的响应文件,我的应用程序在设备准备就绪时已加载到网络上,我希望当单击文件或在网络上下载文件时,文件进入我的应用程序或我的存储移动设备,而不是在网络上链接下载文件而 .pdf 或扩展名只是与参数和响应文件链接,帮帮我

I tried Add line : YourDirectoryCordovaApp\\platforms\\android\\app\\src\\main\\java\\org\\apache\\cordova\\inappbrowser\\InAppBrowser.java我试过添加行:YourDirectoryCordovaApp\\platforms\\android\\app\\src\\main\\java\\org\\apache\\cordova\\inappbrowser\\InAppBrowser.java

     this.inAppWebView.setDownloadListener(new DownloadListener() {
    @Override
    public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) {
        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
        request.setMimeType(mimeType);
        //------------------------COOKIE!!------------------------
        String cookies = CookieManager.getInstance().getCookie(url);
        request.addRequestHeader("cookie", cookies);
        //------------------------COOKIE!!------------------------
        request.addRequestHeader("User-Agent", userAgent);
        request.setDescription("Downloading file...");
        request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimeType));
        request.allowScanningByMediaScanner();
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(url, contentDisposition, mimeType));
      //  DownloadManager dm = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
        DownloadManager dm = (DownloadManager) inAppWebView.getContext().getSystemService(inAppWebView.getContext().DOWNLOAD_SERVICE);

        dm.enqueue(request);
       // Toast.makeText(getApplicationContext(), "Downloading File", Toast.LENGTH_LONG).show();
    }
});

And Great...success download, But How with Plugin Cordova for download on inappbrowser please, tell me name of plugin to download respone file ?很好...成功下载,但是如何使用插件 Cordova 在 inappbrowser 上下载,请告诉我下载响应文件的插件名称?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM