【发布时间】:2011-01-14 16:37:16
【问题描述】:
有没有办法在 Linux bash 脚本中找出文件的 MIME 类型(或者称为“Content-Type”?)?
我需要它的原因是因为 ImageShack 似乎需要它来上传文件,因为某种原因它会将 .png 文件检测为 application/octet-stream 文件。
我检查了文件,确实是 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
【问题讨论】:
标签: linux bash content-type mime mime-types