简体   繁体   English

如何下载文件MIME类型的图像?

[英]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.

相关问题 如何仅使用javascript确定文档的mime类型? - How can I determine the mime-type of a document using javascript only? 如何从 Base 64 字符串中获取 MIME-TYPE? - How to get MIME-TYPE from Base 64 String? 为什么Chrome在粘贴时会将图像数据转换为“image / png”mime-type? - Why Chrome convert the image data to “image/png” mime-type when paste? 我可以通过JavaScript获得图像的文件大小和mime类型吗(仅限FireFox / Gecko / Mozilla) - Can I get an image's file size and mime-type via JavaScript (FireFox/Gecko/Mozilla only) Node js:如何获取文件签名头而不是mime-type? - Node js: How to get file signature headers instead of mime-type? Firefox中HTTP上传的.js文件的mime类型自动检测失败 - mime-type autodetection of .js file fails for http upload in firefox javascript 模块的正确 mime 类型应该是什么? - What should the correct mime-type be for javascript modules? 在Tomcat中更改.xml.gz的mime类型 - Changing mime-type for .xml.gz in Tomcat 资源被解释为文档,但以MIME类型image / svg + xml传输: - Resource interpreted as Document but transferred with MIME type image/svg+xml: javascript mime-type中的多余文本(几种公认的js mime类型除外) - extra texts in javascript mime-type (Other than several recognized js mime types)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM