Prefer to determine an attachment’s file extension for its file name if possible.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 0137e01aff
commit 4506064aa6

@ -216,6 +216,12 @@ class SignalAttachment: NSObject {
// Returns the file extension for this attachment or nil if no file extension
// can be identified.
var fileExtension: String? {
if let filename = filename {
let fileExtension = (filename as NSString).pathExtension
if fileExtension.characters.count > 0 {
return fileExtension
}
}
if dataUTI == SignalAttachment.kOversizeTextAttachmentUTI {
return "txt"
}

Loading…
Cancel
Save