support sending all files

use generic mimetype when file has unknown extension

// FREEBIE
This commit is contained in:
Michael Kirk 2017-04-26 17:53:17 -04:00
parent 93fe122323
commit 822f5c8415
1 changed files with 2 additions and 9 deletions

View File

@ -12,7 +12,6 @@ enum SignalAttachmentError: Error {
case couldNotParseImage
case couldNotConvertToJpeg
case invalidFileFormat
case unknownType
}
extension SignalAttachmentError: LocalizedError {
@ -30,8 +29,6 @@ extension SignalAttachmentError: LocalizedError {
return NSLocalizedString("ATTACHMENT_ERROR_COULD_NOT_CONVERT_TO_JPEG", comment: "Attachment error message for image attachments which could not be converted to JPEG")
case .invalidFileFormat:
return NSLocalizedString("ATTACHMENT_ERROR_INVALID_FILE_FORMAT", comment: "Attachment error message for attachments with an invalid file format")
case .unknownType:
return NSLocalizedString("ATTACHMENT_ERROR_UNKNOWN_TYPE", comment: "Attachment error message for attachments with an invalid file format")
}
}
}
@ -114,10 +111,6 @@ class SignalAttachment: NSObject {
self.dataUTI = dataUTI
self.filename = filename
super.init()
if self.mimeType == nil {
error = .unknownType
}
}
// MARK: Methods
@ -174,7 +167,7 @@ class SignalAttachment: NSObject {
// Returns the MIME type for this attachment or nil if no MIME type
// can be identified.
var mimeType: String? {
var mimeType: String {
if dataUTI == SignalAttachment.kOversizeTextAttachmentUTI {
return OWSMimeTypeOversizeTextMessage
}
@ -182,7 +175,7 @@ class SignalAttachment: NSObject {
return OWSMimeTypeUnknownForTests
}
guard let mimeType = UTTypeCopyPreferredTagWithClass(dataUTI as CFString, kUTTagClassMIMEType) else {
return nil
return OWSMimeTypeApplicationOctetStream
}
return mimeType.takeRetainedValue() as String
}