duandongjin5647 2016-11-15 03:53
浏览 460
已采纳

Golang“ net / http” DetectContentType错误

Use DetectContentType to detect the uploaded file content-type, but the result is always application/octet-stream.this is just the default return in this function.

So what's the problem?

  • 写回答

1条回答 默认 最新

  • doulaopu2343 2016-11-15 04:54
    关注

    The standard library's code is only supposed to detect certain types (like HTML that contains one of a few common tags) according to a certain standardized algorithm--more in https://golang.org/src/net/http/sniff.go. You could use github.com/rakyll/magicmime, which uses libmagic and cgo to guess at more file types.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao