From 6c089f737b3f07f34caac802b990f5d19421f644 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Sun, 3 Mar 2019 14:23:54 -0800 Subject: [PATCH] Not sure why, but mimeType is not always populated --- .../Bridge/Operations/MBIMFetchAttachmentOperation.m | 7 +++++++ kordophone/Bridge/Operations/Utilities/MBIMDataResponse.m | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/kordophone/Bridge/Operations/MBIMFetchAttachmentOperation.m b/kordophone/Bridge/Operations/MBIMFetchAttachmentOperation.m index 114afd0..b7cc8b7 100644 --- a/kordophone/Bridge/Operations/MBIMFetchAttachmentOperation.m +++ b/kordophone/Bridge/Operations/MBIMFetchAttachmentOperation.m @@ -54,6 +54,13 @@ } NSString *mimeType = [transfer mimeType]; + // It's unusual, but if this is nil, try to guess the MIME type based on the filename + if (!mimeType) { + NSString *extension = [[localPath pathExtension] lowercaseString]; + + // XXX: REALLY hacky + mimeType = [NSString stringWithFormat:@"image/%@", extension]; + } response = [[MBIMDataResponse alloc] initWithData:responseData contentType:mimeType]; } while (0); diff --git a/kordophone/Bridge/Operations/Utilities/MBIMDataResponse.m b/kordophone/Bridge/Operations/Utilities/MBIMDataResponse.m index e6ea79d..8758de0 100644 --- a/kordophone/Bridge/Operations/Utilities/MBIMDataResponse.m +++ b/kordophone/Bridge/Operations/Utilities/MBIMDataResponse.m @@ -25,7 +25,7 @@ - (NSDictionary *)httpHeaders { return @{ - @"Content-Type" : _contentType + @"Content-Type" : _contentType ?: @"application/octet-stream" }; }