简体   繁体   English

图片网址以.Zip格式下载

[英]Image URL is downloaded as .Zip format

I have used DownloadManager class for image download. 我已经使用DownloadManager类进行图像下载。 When I have used below image url in browser it is working fine. 当我在浏览器中使用下面的图片网址时,它工作正常。 but when i have downloaded that image url using DownloadManager it is getting .zip format. 但是当我使用DownloadManager下载该图像网址时,它的格式为.zip。

Image Url : Here 图片网址: 此处

Below is my code of download Manager : 以下是我的下载管理器代码:

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");
    }

The provided URL returns zip as a type. 提供的URL返回zip作为一种类型。 You can check that using any dev tool on your browser as demonstrated in this screen shot 如屏幕截图所示,您可以使用浏览器上的任何开发工具进行检查 在此处输入图片说明

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

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