图片 URL 下载为 .Zip 格式
Image URL is downloaded as .Zip format
我使用 DownloadManager class 下载图片。当我在浏览器中使用下面的图像 url 时,它工作正常。但是当我使用 DownloadManager 下载该图像 url 时,它正在获取 .zip 格式。
图片 Url : 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");
}
提供的 URL returns zip 作为类型。您可以检查是否使用浏览器上的任何开发工具,如此屏幕截图所示
我使用 DownloadManager class 下载图片。当我在浏览器中使用下面的图像 url 时,它工作正常。但是当我使用 DownloadManager 下载该图像 url 时,它正在获取 .zip 格式。
图片 Url : 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");
}
提供的 URL returns zip 作为类型。您可以检查是否使用浏览器上的任何开发工具,如此屏幕截图所示