场景:
如下图,比如客户上传类型为wps类型的附件,在某些服务器上就会提示安全问题不允许上传
原因:
附件会验证请求头的content-Type,文件类型必须允许上传,并且Content-Type的值必须和服务器文件配置的类型值必须要一致,标准产品的wps的Content-Type是:application/vnd.ms-works,application/octet-stream,出现此处错误是content-Type的值【application/kswps】不满足
可以通过抓包工具fidder看下请求头的content-Type,如下图:application/kswps
解决方案:
找下应用服务器目录路径:{安装目录}\eas\server\properties\shr,查看此目录下面是否存在文件shrMimeTypes.properties
如果不存在,则新建文件shrMimeTypes.properties
按类型进行新增配置,格式为【KEY=VALUE】,其中,KEY为文件类型,VALUE为请求的响应头的类型content-Type的值,如:pdf=application/pdf
举例:
以wps的配置为例,如果没有就新增,新增结果如下:
wps=application/vnd.ms-works,application/octet-stream,application/kswps
如果有wps的配置,直接修改,在后面用逗号区分,增加application/kswps
wps=application/vnd.ms-works,application/octet-stream,application/kswps
其他类型可以按此方式进行类似处理
odf,需要在该配置文件中新增:
odf=application/odf,application/octet-stream
调整完毕后,需要重启服务,如果是双机及以上,每台机器相应位置都需要修改
上面配置完毕如果出现如下错误
需要参考文章解决:https://vip.kingdee.com/article/420620490928135680?productLineId=10&lang=zh-CN
附上标准产品目前支持的类型和请求头值
txt=text/plain pdf=application/pdf doc=application/msword,application/wps-office.doc docx=application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/wps-office.docx xls=application/vnd.ms-excel/application,octet-stream,application/wps-office.xls xlsx=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/octet-stream,application/wps-office.xlsx xlsm=application/vnd.ms-excel.sheet.macroEnabled.12,application/octet-stream,application/wps-office.xlsm ppt=application/vnd.ms-powerpoint,application/wps-office.ppt pptx=application/vnd.openxmlformats-officedocument.presentationml.presentation,application/wps-office.pptx rft=application/rtf,application/octet-stream rtf=application/rtf,application/msword,application/octet-stream jpg=image/jpeg png=image/png bmp=image/bmp gif=image/gif jpeg=image/jpeg tiff=image/tiff tif=image/tiff rar=application/x-rar-compressed,application/octet-stream,application/x-compressed,application/vnd.rar zip=application/zip,application/x-zip-compressed,application/x-compressed,application/octet-stream dat=application/octet-stream hrl=application/octet-stream key=application/vnd.apple.keynote,application/octet-stream msg=application/vnd.ms-outlook,application/octet-stream cad=application/vnd.visio,application/octet-stream btw=application/btw,application/octet-stream avi=video/avi,video/x-msvideo,application/octet-stream rmvb=application/vnd.rn-realmedia-vbr,application/octet-stream wps=application/vnd.ms-works,application/octet-stream,application/kswps et=application/vnd.ms-excel,application/octet-stream dps=application/vnd.ms-works,application/octet-stream vsd=application/vnd.visio,application/vnd.ms-visio.viewer mod=video/mpeg,application/octet-stream dwg=image/vnd.dwg,application/octet-stream prn=application/prn,application/octet-stream lic=application/x-ms-license,application/octet-stream csv=text/csv,application/vnd.ms-excel
如果文件不在此范围内的,需要通过按上面描述方式进行配置解决
推荐阅读