简体   繁体   English

如何确定由远程服务器托管的文件的mime类型?

[英]How to determine the mime type of a file being hosted by a remote server?

I am trying to determine the MIME type that my web host uses when a request is made for a particular file hosted on his server. 我正在尝试确定在请求其服务器上托管的特定文件时,我的Web主机使用的MIME类型。

Suppose I have a url: 假设我有一个网址:

https://www.mysitename.com/myfile.myextension

And I am trying to determine the MIME type my web host uses for ".myextension" files, how can I do so? 而且我正在尝试确定我的虚拟主机用于“ .myextension”文件的MIME类型,该怎么办?

I figure there must be some way I can make an HTTP request for the file, and as a result there would be some headers, one of which should specify the MIME type of the file. 我认为必须有某种方法可以对文件发出HTTP请求,结果会有一些头,其中之一应指定文件的MIME类型。

How can I do this? 我怎样才能做到这一点? Can I use terminal on OSX or Ubuntu or something ? 我可以在OSX或Ubuntu上使用终端吗? I'm looking for commands to execute from the terminal to determine the MIME type according to the remote server of my file. 我正在寻找要从终端执行的命令,以根据文件的远程服务器确定MIME类型。

EDIT: Forgot to mention - the url is HTTPS. 编辑:忘记提及-该URL是HTTPS。 EDIT: I cannot log into the terminal on the remote server - I can only log into my terminal on my local machine. 编辑:我无法登录到远程服务器上的终端-我只能登录到本地计算机上的终端。

There is a command called mimetype which gives mimetypes information. 有一个称为mimetype的命令可提供mimetypes信息。 You can give it a try. 您可以尝试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM