5
如何找出文件的MIME类型(Content-Type)?
有没有一种方法可以找出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