判断文件名设置不一样的ContentType的类型值,解决了Axure文件变形的问题。javascript
AnsiString TfrmHttpServer::GetContentType(AnsiString strReq)
{
AnsiString strctype;
if(strReq.Pos(".mp4")>0) //文件类型
{
strctype = "video/mpeg4";
}
else if(strReq.Pos(".mp3")>0) //文件类型,
{
strctype = "audio/mp3";
}
else if(strReq.Pos(".jpg")>0) //文件类型,
{
strctype = "image/jpeg";
}
else if(strReq.Pos(".png")>0) //文件类型,
{
strctype = "application/x-png";
}
else if(strReq.Pos(".css")>0) //文件类型,
{
strctype = "text/css";
}
else if(strReq.Pos(".js")>0) //文件类型,
{
strctype = "application/x-javascript";
}
//else if(strReq.Pos(".mp4")>0) //文件类型
//{
// strctype = "video/mpeg4";
//}
else if(strReq.Pos(".ico")>0) //文件类型
{
strctype = "image/x-icon";
}
else if(strReq.Pos(".html")>0|strReq.Pos(".htm")>0|strReq.Pos(".vsp")>0) //文件类型
{
strctype ="text/html";
}
else
{
strctype ="application/octet-stream";//.*( 二进制流,不知道下载文件类型)
}
return strctype;css
//参考文献:response的contentType 几种类型 https://blog.csdn.net/qq_37651267/article/details/91380351
}html
做者:一策书(湘岳阳万江波)java