本文介绍了我怎样才能找到一个文件" MIME类型(?内容类型)QUOT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法找出MIME类型(或者是所谓的Content-Type的...),在Linux bash脚本?
的文件我之所以需要它是因为imageshack似乎需要它来上传文件由于某种原因,检测到.png文件作为一个应用程序/八位字节流...
我心中已经检查的文件,它确实是一个巴纽
$猫/1.png
?PNG
(用随机字符的堆载)
这给我的错误:
$卷曲-Ffileupload=@/1.pnghttp://www.imageshack.us/upload_api.php
<链接和GT;
<错误ID =wrong_file_type>作为文件1.png检测错误的文件类型:应用程序/八位字节流< /错误>
< /链接和GT;
这工作,但我需要指定一个MIME类型。
$卷曲-F文件上传= @ / 1.png;类型=图像/ PNGhttp://www.imageshack.us/upload_api.php
解决方案
使用文件
。例如:
>文件--mime型image.png
image.png:图像/ PNG>文件-b --mime型image.png
图像/ PNG>文件-i FILE_NAME
image.png:图像/ PNG;字符集=二进制
Is there a way to find out the MIME-TYPE (or is it called "Content-Type"...) of a file in a linux bash script?
The reason I need it is because imageshack appears to need it to upload a file as for some reason it detects the .png file as an "application/octet-stream"…
I'v checked the file, and it really is a .png
$ cat /1.png
?PNG
(with a heap load of random characters)
This gives me the error:
$ 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>
This works, but I need to specify a MIME-TYPE.
$ curl -F "fileupload=@/1.png;type=image/png" http://www.imageshack.us/upload_api.php
解决方案
Use file
. Examples:
> 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
这篇关于我怎样才能找到一个文件&QUOT; MIME类型(?内容类型)QUOT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!