[英]How to download an image with document mime-type?
Please take a look at this url : 请看一下这个网址:
https://lh6.ggpht.com/uxLXvxuncWOm2mgU3ChtdGZ0eMp_WJTD4xrVxAKqCJMiR5ibaBbw-VUPJPjcGiqIDRbm=h310 https://lh6.ggpht.com/uxLXvxuncWOm2mgU3ChtdGZ0eMp_WJTD4xrVxAKqCJMiR5ibaBbw-VUPJPjcGiqIDRbm=h310
This link refers to an screenshot of Facebook app on google play. 此链接是指Google Play上Facebook应用的屏幕截图。
As you can see, The mime-type for this link is document. 如您所见,此链接的mime类型是document。 What's this image's real extension ?
该图像的真正扩展名是什么?
Actually, I have a list of +10k screenshots and I want to download them to my local hard disk with exactly the same name as the image url. 实际上,我有一个+ 10k截图的列表,我想将它们下载到与图像URL完全相同名称的本地硬盘上。 But I don't know how .
但是我不知道。 (I could do it easily if there was a known image mime-type on these links, But now that mime-type is document, And files don't have an extension , I don't know how )
(如果这些链接上有一个已知的图像mime类型,那么我可以很容易地做到这一点,但是现在mime-type是document,而文件没有扩展名,我不知道怎么做)
The mime-type returned by the server is not document
, it is actually image/png
. 服务器返回的mime类型不是
document
,实际上是image/png
。
You can get the mime-type returned by the server with code like this: 您可以使用以下代码获取服务器返回的mime类型:
var request = new XMLHttpRequest();
request.open("GET", "https://lh6.ggpht.com/uxLXvxuncWOm2mgU3ChtdGZ0eMp_WJTD4xrVxAKqCJMiR5ibaBbw-VUPJPjcGiqIDRbm=h310");
request.addEventListener("load", function () {
var type = this.getResponseHeader("Content-Type");
console.log(type);
});
request.send();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.