|
|
|
@ -200,11 +200,6 @@ NSString *const OWSMimeTypeUnknownForTests = @"unknown/mimetype";
|
|
|
|
return [[self supportedBinaryDataMIMETypesToExtensionTypes] objectForKey:contentType] != nil;
|
|
|
|
return [[self supportedBinaryDataMIMETypesToExtensionTypes] objectForKey:contentType] != nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ (BOOL)isSupportedMIMEType:(NSString *)contentType {
|
|
|
|
|
|
|
|
return [self isSupportedImageMIMEType:contentType] || [self isSupportedAudioMIMEType:contentType] ||
|
|
|
|
|
|
|
|
[self isSupportedVideoMIMEType:contentType] || [self isSupportedAnimatedMIMEType:contentType];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (BOOL)isSupportedVideoFile:(NSString *)filePath {
|
|
|
|
+ (BOOL)isSupportedVideoFile:(NSString *)filePath {
|
|
|
|
return [[self supportedVideoExtensionTypesToMIMETypes] objectForKey:[filePath pathExtension]] != nil;
|
|
|
|
return [[self supportedVideoExtensionTypesToMIMETypes] objectForKey:[filePath pathExtension]] != nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -294,9 +289,18 @@ NSString *const OWSMimeTypeUnknownForTests = @"unknown/mimetype";
|
|
|
|
} else if ([self isBinaryData:contentType]) {
|
|
|
|
} else if ([self isBinaryData:contentType]) {
|
|
|
|
return [MIMETypeUtil filePathForBinaryData:uniqueId ofMIMEType:contentType inFolder:folder];
|
|
|
|
return [MIMETypeUtil filePathForBinaryData:uniqueId ofMIMEType:contentType inFolder:folder];
|
|
|
|
} else if ([contentType isEqualToString:OWSMimeTypeOversizeTextMessage]) {
|
|
|
|
} else if ([contentType isEqualToString:OWSMimeTypeOversizeTextMessage]) {
|
|
|
|
return [MIMETypeUtil filePathForOversizeTextMessage:uniqueId inFolder:folder];
|
|
|
|
// This file extension is arbitrary - it should never be exposed to the user or
|
|
|
|
|
|
|
|
// be used outside the app.
|
|
|
|
|
|
|
|
return [self filePathForData:uniqueId withFileExtension:@"signal-text-message" inFolder:folder];
|
|
|
|
} else if ([contentType isEqualToString:OWSMimeTypeUnknownForTests]) {
|
|
|
|
} else if ([contentType isEqualToString:OWSMimeTypeUnknownForTests]) {
|
|
|
|
return [MIMETypeUtil filePathForUnknownContent:uniqueId inFolder:folder];
|
|
|
|
// This file extension is arbitrary - it should never be exposed to the user or
|
|
|
|
|
|
|
|
// be used outside the app.
|
|
|
|
|
|
|
|
return [self filePathForData:uniqueId withFileExtension:@"unknown" inFolder:folder];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSString *fileExtension = [self fileExtensionForMIMEType:contentType];
|
|
|
|
|
|
|
|
if (fileExtension) {
|
|
|
|
|
|
|
|
return [self filePathForData:uniqueId withFileExtension:fileExtension inFolder:folder];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DDLogError(@"Got asked for path of file %@ which is unsupported", contentType);
|
|
|
|
DDLogError(@"Got asked for path of file %@ which is unsupported", contentType);
|
|
|
|
@ -350,18 +354,11 @@ NSString *const OWSMimeTypeUnknownForTests = @"unknown/mimetype";
|
|
|
|
stringByAppendingPathExtension:[self getSupportedExtensionFromBinaryDataMIMEType:contentType]];
|
|
|
|
stringByAppendingPathExtension:[self getSupportedExtensionFromBinaryDataMIMEType:contentType]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSString *)filePathForOversizeTextMessage:(NSString *)uniqueId inFolder:(NSString *)folder {
|
|
|
|
+ (NSString *)filePathForData:(NSString *)uniqueId
|
|
|
|
// This file extension is arbitrary - it should never be exposed to the user or
|
|
|
|
withFileExtension:(NSString *)fileExtension
|
|
|
|
// be used outside the app.
|
|
|
|
inFolder:(NSString *)folder
|
|
|
|
return [[folder stringByAppendingFormat:@"/%@", uniqueId]
|
|
|
|
{
|
|
|
|
stringByAppendingPathExtension:@"signal-text-message"];
|
|
|
|
return [[folder stringByAppendingFormat:@"/%@", uniqueId] stringByAppendingPathExtension:fileExtension];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSString *)filePathForUnknownContent:(NSString *)uniqueId inFolder:(NSString *)folder {
|
|
|
|
|
|
|
|
// This file extension is arbitrary - it should never be exposed to the user or
|
|
|
|
|
|
|
|
// be used outside the app.
|
|
|
|
|
|
|
|
return [[folder stringByAppendingFormat:@"/%@", uniqueId]
|
|
|
|
|
|
|
|
stringByAppendingPathExtension:@"unknown"];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if TARGET_OS_IPHONE
|
|
|
|
#if TARGET_OS_IPHONE
|
|
|
|
|