I'm learning swift , and I made a table with cells that show an image ,and classes in groups by MIME TYPE (using path extension). I had a question about extensions. If the images (for example, it could be a video or a pdf) are taken from internet , i'm not sure if they have the extension or not how can I get the MIMEtype of a file inside my file System without using path extension ? PS :Sorry for my bad english it's not my native language
Assuming you are receiving your data as NSData, follow this Post: https://stackoverflow.com/a/5042365/2798777
In Swift for example:
var c = [UInt32](count: 1, repeatedValue: 0)
(data as! NSData).getBytes(&c, length: 1)
switch (c[0]) {
case 0xFF, 0x89, 0x00:
println("image")
case 0x47:
println("gif")
default:
println("unknown: \(c[0])")
}