图像URL以.Zip格式下载

时间:2018-02-27 14:32:49

标签: android android-download-manager

我已经使用DownloadManager类进行图像下载。当我在浏览器中使用下面的图像网址时它工作正常。但是当我使用DownloadManager下载该图像网址时,它将获得.zip格式。

图片网址:Here

以下是我的下载管理器代码:

private void startDownload(String url) {
        DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
        Uri Download_Uri = Uri.parse(url);
        DownloadManager.Request request = new DownloadManager.Request(Download_Uri);
        request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
        request.setAllowedOverRoaming(true);
        MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
        String mimeString = mimeTypeMap.getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(url));
        request.setMimeType(mimeString);
        request.setTitle(getString(R.string.app_name));
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        //Set a description of this download, to be displayed in notifications (if enabled)
        request.setDescription("Downloading " + txtDocName.getText().toString());
        //Set the local destination for the downloaded file to a path within the application's external files directory
        request.setDestinationInExternalFilesDir(this, Environment.DIRECTORY_DOWNLOADS, System.currentTimeMillis() + ".jpeg");
        downloadManager.enqueue(request);
        AppLog.showD(TAG, "downloadind started");
    }

1 个答案:

答案 0 :(得分:0)

提供的URL将zip作为类型返回。您可以使用浏览器上的任何开发工具进行检查,如此屏幕截图所示 enter image description here

相关问题