<分区>
有什么方法可以获取 URL 文件的 MIME TYPE?
例如:http://example.com/photo.jpg
获取它是一个 jpg/应用程序或类似的。
谢谢
最佳答案
尝试 curl -I <url>
.这应该向您显示 header ,尤其是 Content-Type
由服务器发送。
例子:
> curl -I "https://www.gravatar.com/avatar/fd43775c1ea617f12187cab9785ef2d0?s=32&d=identicon&r=PG&f=1"
HTTP/1.1 200 OK
Accept-Ranges: bytes
Access-Control-Allow-Origin: *
Cache-Control: max-age=300
Content-Type: image/png
Date: Mon, 14 Dec 2015 09:48:41 GMT
Expires: Mon, 14 Dec 2015 09:53:41 GMT
Last-Modified: Wed, 11 Jan 1984 08:00:00 GMT
Link: <https://www.gravatar.com/avatar/fd43775c1ea617f12187cab9785ef2d0?s=32&d=identicon&r=PG&f=1>; rel="canonical"
Server: ECS (fcn/9F89)
Source-Age: 140
Via: 1.1 varnish-v4
X-Cache: HIT
X-Varnish: 336435067 334859069
Content-Length: 768
请注意,服务器发送的内容类型不一定是真实的内容类型。
关于linux - 如何在 Linux 中获取 URL 的 Mime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34220281/