【问题标题】:Golang “net/http” DetectContentType errorGolang “net/http” DetectContentType 错误
【发布时间】:2017-03-28 20:33:25
【问题描述】:

使用DetectContentType检测上传的文件content-type,但结果总是application/octet-stream。这只是这个函数中的默认返回。

那么问题出在哪里?

【问题讨论】:

    标签: go content-type net-http


    【解决方案1】:

    标准库的代码只应该根据某种标准化算法检测某些类型(例如包含几个常见标签之一的 HTML)——更多内容请参见https://golang.org/src/net/http/sniff.go。你可以使用github.com/rakyll/magicmime,它使用 libmagic 和 cgo 来猜测更多的文件类型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-12
      • 2013-02-02
      • 1970-01-01
      • 1970-01-01
      • 2012-11-24
      • 2017-05-07
      • 2015-04-07
      相关资源
      最近更新 更多