Commit a87b6f40672b355c45eb37e8f24e72bd1640d8cc

Authored by 梁星国
1 parent d75ba136

提交导出路径更改,添加测试

CNLiveICloudPicker/CNICloudDocumentPickerController.h
... ... @@ -15,9 +15,6 @@ NS_ASSUME_NONNULL_BEGIN
15 15 /** 主题颜色 */
16 16 @property (strong, nonatomic) UIColor *themeColor;
17 17  
18   -
19   -
20   -
21 18 @end
22 19  
23 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 36 @param url 文件路径
37 37 @param outputPath 导出路径
38 38 @param maxSize 保存的最大尺寸 为 nil 忽略
39   - @param conversationId 群聊为群 ID, 单聊为好友ID (即 会话ID)
40 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 44 文件是否在指定filePath存在 否则是否在iCloudBox存在
... ...
CNLiveICloudPicker/CNICloudManager.m
... ... @@ -79,15 +79,14 @@
79 79  
80 80  
81 81 /**
82   - 保存文件到本地 /Documents/iCloudBox 下
  82 + 保存文件到本地指定路径 默认/Documents/iCloudBox 下
83 83  
84 84 @param url 文件路径
85 85 @param maxSize 保存的最大尺寸 为 nil 忽略
86   - @param conversationId 群聊为群 ID, 单聊为好友ID (即 会话ID)
87 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 91 if (![CNICloudManager iCloudEnable]) {
93 92 callBackContent(nil, false, @"请在设置->AppleID、iCloud->iCloud中打开访问权限",code101);
... ... @@ -97,6 +96,10 @@
97 96 NSArray *array = [[url absoluteString] componentsSeparatedByString:@"/"];
98 97 NSString *fileName = [array lastObject];
99 98 fileName = [fileName stringByRemovingPercentEncoding];
  99 + if (!fileName) {
  100 + callBackContent(nil, false, @"请在设置->AppleID、iCloud->iCloud中打开访问权限",code104);
  101 + return;
  102 + }
100 103  
101 104 [CNICloudManager downloadWithDocumentURL:url callBack:^(bool success ,NSData *data, float size) {
102 105  
... ... @@ -119,13 +122,17 @@
119 122  
120 123 NSString *dataPath = [NSString string];
121 124 if ([NSString isEmpty:outputPath]) {
122   - dataPath = kICloudBoxDownLoadPath;
  125 + dataPath = kICloudBoxPath;
123 126 }else {
124 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 136 BOOL isWrite = [data writeToURL:writeUrl options:NSDataWritingAtomic error:nil];
130 137  
131 138 if (isWrite) {
... ...