GoogleCloudPlatform / GoogleCloudPlatform/gcsfuse
Content type from file, not from extension
- Dominant language
- Go
- Stars
- 2.3k
- Forks
- 510
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 35
Description
https://github.com/GoogleCloudPlatform/gcsfuse/issues/155 introduced automatically setting `contentType` based on the file suffix. I was wondering about this design: wouldn't it be more accurate to check the file contents by, say, checking the checking the [magic numbers](https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) signature and only falling back to go's (arguably quite limited) [list of extensions](https://github.com/golang/go/blob/master/src/mime/type.go#L60) if a proper mime type cannot be found?
Here is an example of a [golang lib](https://github.com/gabriel-vasile/mimetype/blob/v1.4.3/supported_mimes.md) with quite an extensive list of files detected. The ubiquitous [`file`](https://www.darwinsys.com/file/) command might be helpful, too.
Contributor guide
Assessment
This issue has not been assessed yet.