Commit a87b6f40672b355c45eb37e8f24e72bd1640d8cc
1 parent
d75ba136
提交导出路径更改,添加测试
Showing
5 changed files
with
14 additions
and
57 deletions
CNLiveICloudPicker/CNICloudDocumentPickerController.h
| @@ -15,9 +15,6 @@ NS_ASSUME_NONNULL_BEGIN | @@ -15,9 +15,6 @@ NS_ASSUME_NONNULL_BEGIN | ||
| 15 | /** 主题颜色 */ | 15 | /** 主题颜色 */ |
| 16 | @property (strong, nonatomic) UIColor *themeColor; | 16 | @property (strong, nonatomic) UIColor *themeColor; |
| 17 | 17 | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | @end | 18 | @end |
| 22 | 19 | ||
| 23 | NS_ASSUME_NONNULL_END | 20 | NS_ASSUME_NONNULL_END |
CNLiveICloudPicker/CNICloudDocumentPickerManager.h deleted
100644 → 0
| 1 | -// | ||
| 2 | -// CNICloudDocumentPickerManager.h | ||
| 3 | -// iCloud_测试 | ||
| 4 | -// | ||
| 5 | -// Created by 梁星国 on 2018/10/12. | ||
| 6 | -// Copyright © 2018年 梁星国. All rights reserved. | ||
| 7 | -// | ||
| 8 | - | ||
| 9 | -#import <Foundation/Foundation.h> | ||
| 10 | -#import "CNICloudDocumentPickerController.h" | ||
| 11 | - | ||
| 12 | -NS_ASSUME_NONNULL_BEGIN | ||
| 13 | - | ||
| 14 | -typedef NS_ENUM(NSUInteger, CNICloudDocumentType) { | ||
| 15 | - CNICloudDocumentTypeUrl, // | ||
| 16 | - CNICloudDocumentTypeUrls, | ||
| 17 | - CNICloudDocumentTypeUTIs, | ||
| 18 | -} NS_ENUM_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED; | ||
| 19 | - | ||
| 20 | - | ||
| 21 | -@interface CNICloudDocumentPickerManager : NSObject | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | -@end | ||
| 26 | - | ||
| 27 | -NS_ASSUME_NONNULL_END |
CNLiveICloudPicker/CNICloudDocumentPickerManager.m deleted
100644 → 0
| 1 | -// | ||
| 2 | -// CNICloudDocumentPickerManager.m | ||
| 3 | -// iCloud_测试 | ||
| 4 | -// | ||
| 5 | -// Created by 梁星国 on 2018/10/12. | ||
| 6 | -// Copyright © 2018年 梁星国. All rights reserved. | ||
| 7 | -// | ||
| 8 | - | ||
| 9 | -#import "CNICloudDocumentPickerManager.h" | ||
| 10 | -#import "CNICloudDocumentPickerController.h" | ||
| 11 | - | ||
| 12 | - | ||
| 13 | -@implementation CNICloudDocumentPickerManager | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | -@end |
CNLiveICloudPicker/CNICloudManager.h
| @@ -36,10 +36,9 @@ NS_ASSUME_NONNULL_BEGIN | @@ -36,10 +36,9 @@ NS_ASSUME_NONNULL_BEGIN | ||
| 36 | @param url 文件路径 | 36 | @param url 文件路径 |
| 37 | @param outputPath 导出路径 | 37 | @param outputPath 导出路径 |
| 38 | @param maxSize 保存的最大尺寸 为 nil 忽略 | 38 | @param maxSize 保存的最大尺寸 为 nil 忽略 |
| 39 | - @param conversationId 群聊为群 ID, 单聊为好友ID (即 会话ID) | ||
| 40 | @param callBackContent 保存h的路径 url,是否保存成功,保存失败的描述 | 39 | @param callBackContent 保存h的路径 url,是否保存成功,保存失败的描述 |
| 41 | */ | 40 | */ |
| 42 | -+ (void)saveWithDocumentURL:(NSURL *)url outputPath:(NSString *)outputPath maxSize:(float)maxSize conversationId:(NSString *)conversationId callBackContent:(void(^)(CNICloudDocumentModel *model, BOOL success, NSString * msg, NSInteger code))callBackContent; | 41 | ++ (void)saveWithDocumentURL:(NSURL *)url outputPath:(NSString *)outputPath maxSize:(float)maxSize callBackContent:(void(^)(CNICloudDocumentModel *model, BOOL success, NSString * msg, NSInteger code))callBackContent; |
| 43 | 42 | ||
| 44 | /** | 43 | /** |
| 45 | 文件是否在指定filePath存在 否则是否在iCloudBox存在 | 44 | 文件是否在指定filePath存在 否则是否在iCloudBox存在 |
CNLiveICloudPicker/CNICloudManager.m
| @@ -79,15 +79,14 @@ | @@ -79,15 +79,14 @@ | ||
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | /** | 81 | /** |
| 82 | - 保存文件到本地 /Documents/iCloudBox 下 | 82 | + 保存文件到本地指定路径 默认/Documents/iCloudBox 下 |
| 83 | 83 | ||
| 84 | @param url 文件路径 | 84 | @param url 文件路径 |
| 85 | @param maxSize 保存的最大尺寸 为 nil 忽略 | 85 | @param maxSize 保存的最大尺寸 为 nil 忽略 |
| 86 | - @param conversationId 群聊为群 ID, 单聊为好友ID (即 会话ID) | ||
| 87 | @param callBackContent 保存h的路径 url,是否保存成功,保存失败的描述 | 86 | @param callBackContent 保存h的路径 url,是否保存成功,保存失败的描述 |
| 88 | */ | 87 | */ |
| 89 | 88 | ||
| 90 | -+ (void)saveWithDocumentURL:(NSURL *)url outputPath:(NSString *)outputPath maxSize:(float)maxSize conversationId:(NSString *)conversationId callBackContent:(void(^)(CNICloudDocumentModel *model, BOOL success, NSString * msg, NSInteger code))callBackContent { | 89 | ++ (void)saveWithDocumentURL:(NSURL *)url outputPath:(NSString *)outputPath maxSize:(float)maxSize callBackContent:(void(^)(CNICloudDocumentModel *model, BOOL success, NSString * msg, NSInteger code))callBackContent { |
| 91 | 90 | ||
| 92 | if (![CNICloudManager iCloudEnable]) { | 91 | if (![CNICloudManager iCloudEnable]) { |
| 93 | callBackContent(nil, false, @"请在设置->AppleID、iCloud->iCloud中打开访问权限",code101); | 92 | callBackContent(nil, false, @"请在设置->AppleID、iCloud->iCloud中打开访问权限",code101); |
| @@ -97,6 +96,10 @@ | @@ -97,6 +96,10 @@ | ||
| 97 | NSArray *array = [[url absoluteString] componentsSeparatedByString:@"/"]; | 96 | NSArray *array = [[url absoluteString] componentsSeparatedByString:@"/"]; |
| 98 | NSString *fileName = [array lastObject]; | 97 | NSString *fileName = [array lastObject]; |
| 99 | fileName = [fileName stringByRemovingPercentEncoding]; | 98 | fileName = [fileName stringByRemovingPercentEncoding]; |
| 99 | + if (!fileName) { | ||
| 100 | + callBackContent(nil, false, @"请在设置->AppleID、iCloud->iCloud中打开访问权限",code104); | ||
| 101 | + return; | ||
| 102 | + } | ||
| 100 | 103 | ||
| 101 | [CNICloudManager downloadWithDocumentURL:url callBack:^(bool success ,NSData *data, float size) { | 104 | [CNICloudManager downloadWithDocumentURL:url callBack:^(bool success ,NSData *data, float size) { |
| 102 | 105 | ||
| @@ -119,13 +122,17 @@ | @@ -119,13 +122,17 @@ | ||
| 119 | 122 | ||
| 120 | NSString *dataPath = [NSString string]; | 123 | NSString *dataPath = [NSString string]; |
| 121 | if ([NSString isEmpty:outputPath]) { | 124 | if ([NSString isEmpty:outputPath]) { |
| 122 | - dataPath = kICloudBoxDownLoadPath; | 125 | + dataPath = kICloudBoxPath; |
| 123 | }else { | 126 | }else { |
| 124 | dataPath = outputPath; | 127 | dataPath = outputPath; |
| 125 | } | 128 | } |
| 126 | - NSURL *writeUrl = [[NSURL alloc]initFileURLWithPath:dataPath]; | ||
| 127 | - [CNICloudFileHelper createDirectoryAtPath:dataPath]; | ||
| 128 | 129 | ||
| 130 | + BOOL isCreate = [CNICloudFileHelper createDirectoryAtPath:dataPath]; | ||
| 131 | + if (!isCreate) { | ||
| 132 | + callBackContent(nil,YES,@"文件创建失败",code104); | ||
| 133 | + return; | ||
| 134 | + } | ||
| 135 | + NSURL *writeUrl = [[NSURL alloc]initFileURLWithPath:[dataPath stringByAppendingString:fileName]]; | ||
| 129 | BOOL isWrite = [data writeToURL:writeUrl options:NSDataWritingAtomic error:nil]; | 136 | BOOL isWrite = [data writeToURL:writeUrl options:NSDataWritingAtomic error:nil]; |
| 130 | 137 | ||
| 131 | if (isWrite) { | 138 | if (isWrite) { |