[英]File downloads as html instead of file I want to download, how to fix this?
I want to write a download service on android. 我想在Android上编写下载服务。 However when I tried it, it downloads files as HTML not as .jpg for example. 但是,当我尝试使用它时,它会将文件下载为HTML,而不是.jpg。 How do I fix it ? 我如何解决它 ?
Nevermind I solved it. 没关系,我解决了。 Just needed to add authorization key to my website as header. 只需向我的网站添加授权密钥作为标题即可。 Thanks all. 谢谢大家
Uri uri = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(uri);
String filename = URLUtil.guessFileName(uri.getEncodedPath(), null, "image/jpeg");
request.setDescription(filename);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.