Commit 99af3201d23d25ed4428487a71ac1e1e0ba89548
1 parent
cb948dc4
0.1.20 获取发送 图片 和视频 消息时的临时文件路径
Showing
3 changed files
with
29 additions
and
21 deletions
CNLiveBusinessTools.podspec
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | 8 | ||
| 9 | Pod::Spec.new do |s| | 9 | Pod::Spec.new do |s| |
| 10 | s.name = 'CNLiveBusinessTools' | 10 | s.name = 'CNLiveBusinessTools' |
| 11 | - s.version = '0.1.19' | 11 | + s.version = '0.1.20' |
| 12 | s.summary = '业务工具集合组件.' | 12 | s.summary = '业务工具集合组件.' |
| 13 | 13 | ||
| 14 | # This description is used to generate tags and improve search results. | 14 | # This description is used to generate tags and improve search results. |
CNLiveBusinessTools/Classes/CNLiveBusinessTools.h
| @@ -117,7 +117,8 @@ typedef NS_ENUM(NSInteger, CNFileType) { | @@ -117,7 +117,8 @@ typedef NS_ENUM(NSInteger, CNFileType) { | ||
| 117 | /// 发送图片或视频消息时上传给IM的文件路径,发送消息成功后或者失败后会把这个图片或视频文件拷贝到对应的 image 或者video 文件夹下 | 117 | /// 发送图片或视频消息时上传给IM的文件路径,发送消息成功后或者失败后会把这个图片或视频文件拷贝到对应的 image 或者video 文件夹下 |
| 118 | /// @param fileName 临时图片或视频名字 | 118 | /// @param fileName 临时图片或视频名字 |
| 119 | + (NSString *)chatImageAndVideoUploadIMCachePath:(NSString *)fileName; | 119 | + (NSString *)chatImageAndVideoUploadIMCachePath:(NSString *)fileName; |
| 120 | - | 120 | +///获取 临时发送图片或视频保存的文件夹 |
| 121 | ++ (NSString *)getChatImageAndVideoUploadIMCacheDirectory; | ||
| 121 | /// 删除聊天 图片 和 视频 上传时的临时文件 | 122 | /// 删除聊天 图片 和 视频 上传时的临时文件 |
| 122 | + (BOOL )deleteChatImageAndVideoUploadImCache; | 123 | + (BOOL )deleteChatImageAndVideoUploadImCache; |
| 123 | 124 |
CNLiveBusinessTools/Classes/CNLiveBusinessTools.m
| @@ -849,30 +849,37 @@ | @@ -849,30 +849,37 @@ | ||
| 849 | 849 | ||
| 850 | return filePath; | 850 | return filePath; |
| 851 | } | 851 | } |
| 852 | - | 852 | +/// 发送图片或视频消息时上传给IM的文件路径,发送消息成功后或者失败后会把这个图片或视频文件拷贝到对应的 image 或者video 文件夹下 |
| 853 | +/// @param fileName 临时图片或视频名字 | ||
| 853 | + (NSString *)chatImageAndVideoUploadIMCachePath:(NSString *)fileName; | 854 | + (NSString *)chatImageAndVideoUploadIMCachePath:(NSString *)fileName; |
| 854 | { | 855 | { |
| 855 | - NSString *temp = [NSString stringWithFormat:@"Documents/%@/image_video_temp", CNUserShareModel.uid]; | ||
| 856 | - | ||
| 857 | - NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:temp]; | ||
| 858 | - | ||
| 859 | - NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
| 860 | - | ||
| 861 | - BOOL isDir = NO; | ||
| 862 | - | ||
| 863 | - // fileExistsAtPath 判断一个文件或目录是否有效,isDirectory判断是否一个目录 | ||
| 864 | - BOOL existed = [fileManager fileExistsAtPath:filePath isDirectory:&isDir]; | ||
| 865 | - | ||
| 866 | - if ( !(isDir == YES && existed == YES) ) { | ||
| 867 | - | ||
| 868 | - // 在 Documents 目录下创建一个 image_video_temp 目录 | ||
| 869 | - [fileManager createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil]; | ||
| 870 | - } | ||
| 871 | - | 856 | + NSString *temp = [CNLiveBusinessTools getChatImageAndVideoUploadIMCacheDirectory]; |
| 872 | filePath = [filePath stringByAppendingPathComponent:fileName]; | 857 | filePath = [filePath stringByAppendingPathComponent:fileName]; |
| 873 | return filePath; | 858 | return filePath; |
| 874 | } | 859 | } |
| 875 | -+ (BOOL )deleteChatImageAndVideoUploadImCache; | 860 | +//获取 临时发送图片或视频保存的文件夹地址 |
| 861 | ++ (NSString *)getChatImageAndVideoUploadIMCacheDirectory; | ||
| 862 | +{ | ||
| 863 | + NSString *temp = [NSString stringWithFormat:@"Documents/%@/image_video_temp", CNUserShareModel.uid]; | ||
| 864 | + | ||
| 865 | + NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:temp]; | ||
| 866 | + | ||
| 867 | + NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
| 868 | + | ||
| 869 | + BOOL isDir = NO; | ||
| 870 | + | ||
| 871 | + // fileExistsAtPath 判断一个文件或目录是否有效,isDirectory判断是否一个目录 | ||
| 872 | + BOOL existed = [fileManager fileExistsAtPath:filePath isDirectory:&isDir]; | ||
| 873 | + | ||
| 874 | + if ( !(isDir == YES && existed == YES) ) { | ||
| 875 | + | ||
| 876 | + // 在 Documents 目录下创建一个 image_video_temp 目录 | ||
| 877 | + [fileManager createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil]; | ||
| 878 | + } | ||
| 879 | + return filePath; | ||
| 880 | +} | ||
| 881 | +/// 删除聊天 图片 和 视频 上传时的临时文件 | ||
| 882 | ++ (BOOL )deleteChatImageAndVideoUploadImCache | ||
| 876 | { | 883 | { |
| 877 | NSString *temp = [NSString stringWithFormat:@"Documents/%@/image_video_temp", CNUserShareModel.uid]; | 884 | NSString *temp = [NSString stringWithFormat:@"Documents/%@/image_video_temp", CNUserShareModel.uid]; |
| 878 | 885 |