14 lines
338 B
Swift
14 lines
338 B
Swift
|
import UniformTypeIdentifiers
|
||
|
|
||
|
extension URL {
|
||
|
var mimeType: String {
|
||
|
let pathExtension = self.pathExtension
|
||
|
|
||
|
if let uti = UTType(filenameExtension: pathExtension) {
|
||
|
return uti.preferredMIMEType ?? "application/octet-stream"
|
||
|
} else {
|
||
|
return "application/octet-stream"
|
||
|
}
|
||
|
}
|
||
|
}
|