有没有办法找出 Linux bash 脚本中文件的 MIME 类型(或者称为“Content-Type”?)?
我需要它的原因是 ImageShack 似乎需要它来上传文件,因为出于某种原因它会将 .png 文件检测为application/octet-stream
file.
我检查了该文件,它确实是一个PNG图像:
$ cat /1.png
?PNG
(with a heap load of random characters)
这给了我错误:
$ curl -F "fileupload=@/1.png" http://www.imageshack.us/upload_api.php
<links>
<error id="wrong_file_type">Wrong file type detected for file 1.png:application/octet-stream</error>
</links>
这可行,但我需要指定 MIME-TYPE。
$ curl -F "fileupload=@/1.png;type=image/png" http://www.imageshack.us/upload_api.php
Use file
。例子:
> file --mime-type image.png
image.png: image/png
> file -b --mime-type image.png
image/png
> file -i FILE_NAME
image.png: image/png; charset=binary
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)