aofei / mimesniffer Goto Github PK
View Code? Open in Web Editor NEWA MIME type sniffer for Go.
Home Page: https://pkg.go.dev/github.com/aofei/mimesniffer
License: MIT License
A MIME type sniffer for Go.
Home Page: https://pkg.go.dev/github.com/aofei/mimesniffer
License: MIT License
registeredSniffers is a map that may have concurrent access. Therefore it should have a protective lock, probably a sync.RWMutex.
application/json
is widely used in REST APIs, but isn't detected by mimesniffer, nor by the default net/http sniffer.
This would be a useful addition for many people.
Correct sniffing should determine whether the content is valid JSON. If it isn't then the result would be "text/plain". This can be done using encoding/json
via the json.Valid function.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0
I used mimesniffer.Sniff with this MP3 file:
Bagdad cafe - I'm Calling you.mp3.zip
buff, err := file.Open()
head := make([]byte, 512)
_, err = buff.Read(head)
contentType = mimesniffer.Sniff(head)
audio/mpeg or audio/mp3
application/octet-stream (the MIME type of this file isn't recognized)
Could you add this MIME type to mimesniffer.Sniff?
LibreOffice documents are recognized as Zip files. Could you recognize them as OpenDocuments, like https://github.com/gabriel-vasile/mimetype?
This Excel file is recognized as an application/vnd.ms-powerpoint file:
Bibliothèque de macros pour extraire des données de Baan.xls
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.