|
@@ -17,10 +17,20 @@
|
|
#import "KSLocalWebViewController.h"
|
|
#import "KSLocalWebViewController.h"
|
|
#import "RCConnectionManager.h"
|
|
#import "RCConnectionManager.h"
|
|
#import "KSAccompanyWebViewController.h"
|
|
#import "KSAccompanyWebViewController.h"
|
|
|
|
+#import "KSChatConversationViewController.h"
|
|
|
|
+#import "KSMediaManager.h"
|
|
|
|
+#import <AVFoundation/AVFoundation.h>
|
|
|
|
+#import "KSDocumentViewController.h"
|
|
|
|
+#import "KSICloudManager.h"
|
|
|
|
|
|
-//#import "ChatConversationViewController.h"
|
|
|
|
|
|
+typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
+ CHOOSETYPE_XML,
|
|
|
|
+ CHOOSETYPE_MIDI,
|
|
|
|
+ CHOOSETYPE_MP3,
|
|
|
|
+ CHOOSETYPE_ALL,
|
|
|
|
+};
|
|
|
|
|
|
-@interface KSBaseWKWebViewController ()
|
|
|
|
|
|
+@interface KSBaseWKWebViewController ()<UIDocumentPickerDelegate>
|
|
|
|
|
|
@property (nonatomic, assign) BOOL isOutLink; // 外部链接
|
|
@property (nonatomic, assign) BOOL isOutLink; // 外部链接
|
|
|
|
|
|
@@ -34,6 +44,15 @@
|
|
|
|
|
|
@property (nonatomic, assign) BOOL landScape;
|
|
@property (nonatomic, assign) BOOL landScape;
|
|
|
|
|
|
|
|
+/// 选择本地文件 parm
|
|
|
|
+@property (nonatomic, strong) NSMutableDictionary *chooseFileParm;
|
|
|
|
+
|
|
|
|
+@property (nonatomic, strong) KSMediaManager *mediaManager;
|
|
|
|
+
|
|
|
|
+@property (strong, nonatomic) MBProgressHUD *HUD;
|
|
|
|
+
|
|
|
|
+@property (nonatomic, assign) CHOOSETYPE fileChooseType;
|
|
|
|
+
|
|
@end
|
|
@end
|
|
|
|
|
|
@implementation KSBaseWKWebViewController
|
|
@implementation KSBaseWKWebViewController
|
|
@@ -258,9 +277,9 @@
|
|
NSDictionary *valueDic = [parm dictionaryValueForKey:@"content"];
|
|
NSDictionary *valueDic = [parm dictionaryValueForKey:@"content"];
|
|
NSString *name = [valueDic stringValueForKey:@"name"];
|
|
NSString *name = [valueDic stringValueForKey:@"name"];
|
|
NSString *userId = [NSString stringWithFormat:@"%.0f",[valueDic floatValueForKey:@"userId"]];
|
|
NSString *userId = [NSString stringWithFormat:@"%.0f",[valueDic floatValueForKey:@"userId"]];
|
|
-// ChatConversationViewController *conversationVC = [[ChatConversationViewController alloc] initWithConversationType:ConversationType_PRIVATE targetId:[NSString returnNoNullStringWithString:userId]];
|
|
|
|
-// conversationVC.title = [NSString returnNoNullStringWithString:name];
|
|
|
|
-// [self.navigationController pushViewController:conversationVC animated:YES];
|
|
|
|
|
|
+ KSChatConversationViewController *conversationVC = [[KSChatConversationViewController alloc] initWithConversationType:ConversationType_PRIVATE targetId:[NSString returnNoNullStringWithString:userId]];
|
|
|
|
+ conversationVC.title = [NSString returnNoNullStringWithString:name];
|
|
|
|
+ [self.navigationController pushViewController:conversationVC animated:YES];
|
|
}
|
|
}
|
|
else if ([[parm stringValueForKey:@"api"] isEqualToString:@"openWebView"]) { // 打开新页面
|
|
else if ([[parm stringValueForKey:@"api"] isEqualToString:@"openWebView"]) { // 打开新页面
|
|
NSDictionary *valueDic = [parm dictionaryValueForKey:@"content"];
|
|
NSDictionary *valueDic = [parm dictionaryValueForKey:@"content"];
|
|
@@ -293,16 +312,16 @@
|
|
NSDictionary *valueDic = [parm dictionaryValueForKey:@"content"];
|
|
NSDictionary *valueDic = [parm dictionaryValueForKey:@"content"];
|
|
if ([valueDic stringValueForKey:@"PDF"]) {
|
|
if ([valueDic stringValueForKey:@"PDF"]) {
|
|
NSString *url = [valueDic stringValueForKey:@"downloadUrl"];
|
|
NSString *url = [valueDic stringValueForKey:@"downloadUrl"];
|
|
-// [KSNetworkingManager downloadFileRequestWithFileUrl:url progress:^(int64_t bytesRead, int64_t totalBytes) {
|
|
|
|
-//
|
|
|
|
-// } success:^(NSURL * _Nonnull fileUrl) {
|
|
|
|
-// MJWeakSelf;
|
|
|
|
-// [self KSShowMsg:@"下载成功" promptCompletion:^{
|
|
|
|
-// [weakSelf displaySource:fileUrl];
|
|
|
|
-// }];
|
|
|
|
-// } faliure:^(NSError * _Nonnull error) {
|
|
|
|
-//
|
|
|
|
-// }];
|
|
|
|
|
|
+ [KSNetworkingManager downloadFileRequestWithFileUrl:url progress:^(int64_t bytesRead, int64_t totalBytes) {
|
|
|
|
+
|
|
|
|
+ } success:^(NSURL * _Nonnull fileUrl) {
|
|
|
|
+ MJWeakSelf;
|
|
|
|
+ [self KSShowMsg:@"下载成功" promptCompletion:^{
|
|
|
|
+ [weakSelf displaySource:fileUrl];
|
|
|
|
+ }];
|
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
|
+
|
|
|
|
+ }];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 回调是否刘海屏
|
|
// 回调是否刘海屏
|
|
@@ -397,11 +416,68 @@
|
|
make.top.mas_equalTo(self.view.mas_top).offset(navHeight);
|
|
make.top.mas_equalTo(self.view.mas_top).offset(navHeight);
|
|
}];
|
|
}];
|
|
}
|
|
}
|
|
-// else if ([[parm stringValueForKey:@"api"] isEqualToString:@"enterLiveRoom"]) { // 进入直播间
|
|
|
|
-// NSDictionary *valueDic = [parm dictionaryValueForKey:@"content"];
|
|
|
|
-// NSString *roomId = [valueDic stringValueForKey:@"roomId"];
|
|
|
|
-// [KSEnterLiveroomManager joinLiveWithRoomId:roomId inController:(CustomNavViewController *)self.navigationController];
|
|
|
|
-// }
|
|
|
|
|
|
+ else if ([[parm stringValueForKey:@"api"] isEqualToString:@"chooseFile"]) {
|
|
|
|
+ NSDictionary *valueDic = [parm dictionaryValueForKey:@"content"];
|
|
|
|
+ self.chooseFileParm = [NSMutableDictionary dictionaryWithDictionary:valueDic];
|
|
|
|
+ NSString *typeStr = [valueDic stringValueForKey:@"type"];
|
|
|
|
+ NSInteger maxCount = [valueDic integerValueForKey:@"max"];
|
|
|
|
+ [self chooseFileWithType:typeStr maxNumber:maxCount];
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)chooseFileWithType:(NSString *)typeStr maxNumber:(NSInteger)maxCount {
|
|
|
|
+ if ([typeStr isEqualToString:@"img"]) { // 选择图片上传
|
|
|
|
+ if (maxCount > 9) {
|
|
|
|
+ maxCount = 9;
|
|
|
|
+ }
|
|
|
|
+ [self chooseMediaWithType:MEDIATYPE_PHOTO maxCount:maxCount];
|
|
|
|
+ }
|
|
|
|
+ else if ([typeStr isEqualToString:@"video"]) {
|
|
|
|
+ [self chooseMediaWithType:MEDIATYPE_VIDEO maxCount:1];
|
|
|
|
+ }
|
|
|
|
+ else if ([typeStr isEqualToString:@"file"]) {
|
|
|
|
+ [self chooseDocumentWithType:CHOOSETYPE_ALL];
|
|
|
|
+ }
|
|
|
|
+ else if ([typeStr isEqualToString:@"midi"]) {
|
|
|
|
+ [self chooseDocumentWithType:CHOOSETYPE_MIDI];
|
|
|
|
+ }
|
|
|
|
+ else if ([typeStr isEqualToString:@"mp3"]) {
|
|
|
|
+ [self chooseDocumentWithType:CHOOSETYPE_MP3];
|
|
|
|
+ }
|
|
|
|
+ else if ([typeStr isEqualToString:@"xml"]) {
|
|
|
|
+ [self chooseDocumentWithType:CHOOSETYPE_XML];
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)chooseDocumentWithType:(CHOOSETYPE)fileTyle {
|
|
|
|
+ NSArray *documentTypes = @[@"public.content", @"public.text", @"public.source-code", @"public.image", @"public.audio", @"public.audiovisual-content", @"com.adobe.pdf", @"com.apple.keynote.key", @"com.microsoft.word.doc", @"com.microsoft.excel.xls", @"com.microsoft.powerpoint.ppt"];
|
|
|
|
+ KSDocumentViewController *documentPickerViewController = [[KSDocumentViewController alloc] initWithDocumentTypes:documentTypes inMode:UIDocumentPickerModeImport];
|
|
|
|
+ documentPickerViewController.delegate = self;
|
|
|
|
+// documentPickerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
+ [self presentViewController:documentPickerViewController animated:YES completion:nil];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)chooseMediaWithType:(MEDIATYPE)type maxCount:(NSInteger)maxCount {
|
|
|
|
+ self.mediaManager = [[KSMediaManager alloc] init];
|
|
|
|
+ self.mediaManager.mediaType = type;
|
|
|
|
+ self.mediaManager.maxPhotoNumber = maxCount;
|
|
|
|
+ self.mediaManager.baseCtrl = self;
|
|
|
|
+ self.mediaManager.needCropImage = NO;
|
|
|
|
+ MJWeakSelf;
|
|
|
|
+ [self.mediaManager noAlertCallback:^(NSString * _Nullable videoUrl, NSMutableArray * _Nullable imageArray, NSMutableArray * _Nullable imageAsset) {
|
|
|
|
+
|
|
|
|
+ if (type == MEDIATYPE_PHOTO) {
|
|
|
|
+ [self uploadImageArray:imageArray];
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ NSLog(@"%@", videoUrl);
|
|
|
|
+ // 上传视频
|
|
|
|
+ [weakSelf uploadVideoWithUrl:videoUrl];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }];
|
|
|
|
+ [self.mediaManager pushImagePickerController];
|
|
}
|
|
}
|
|
|
|
|
|
- (UIImage *)imageWithBase64String:(NSString *)base64String {
|
|
- (UIImage *)imageWithBase64String:(NSString *)base64String {
|
|
@@ -818,6 +894,238 @@
|
|
return path;
|
|
return path;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#pragma mark -- 上传图片
|
|
|
|
+
|
|
|
|
+- (void)hudTipWillShow:(BOOL)willShow{
|
|
|
|
+ if (willShow) {
|
|
|
|
+ [self resignFirstResponder];
|
|
|
|
+ UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
|
|
|
+ if (!_HUD) {
|
|
|
|
+ _HUD = [MBProgressHUD showHUDAddedTo:keyWindow animated:YES];
|
|
|
|
+ _HUD.mode = MBProgressHUDModeDeterminateHorizontalBar;
|
|
|
|
+ _HUD.label.text = @"正在上传视频...";
|
|
|
|
+ _HUD.contentColor = [UIColor whiteColor];
|
|
|
|
+ _HUD.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
|
|
|
|
+ _HUD.bezelView.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.8];
|
|
|
|
+ _HUD.removeFromSuperViewOnHide = YES;
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ _HUD.progress = 0;
|
|
|
|
+ [keyWindow addSubview:_HUD];
|
|
|
|
+ [_HUD showAnimated:YES];
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ [_HUD hideAnimated:YES];
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)uploadImageArray:(NSMutableArray *)imageArray {
|
|
|
|
+ [self showhud];
|
|
|
|
+ NSMutableArray *imageDataArray = [NSMutableArray array];
|
|
|
|
+ for (UIImage *image in imageArray) {
|
|
|
|
+ NSData *imgData = [UIImage turnsImaegDataByImage:image];
|
|
|
|
+ [imageDataArray addObject:imgData];
|
|
|
|
+ }
|
|
|
|
+ [KSNetworkingManager multiImageUpload:KS_POST imgDataArray:imageDataArray success:^(NSArray * _Nonnull dics) {
|
|
|
|
+ [self removehub];
|
|
|
|
+ NSDictionary *dic = [dics lastObject];
|
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
|
+ NSMutableArray *urlArray = [NSMutableArray array];
|
|
|
|
+ for (NSDictionary *result in dics) {
|
|
|
|
+ NSDictionary *parm = [result dictionaryValueForKey:@"data"];
|
|
|
|
+ NSString *avatar = [parm stringValueForKey:@"url"];
|
|
|
|
+ [urlArray addObject:avatar];
|
|
|
|
+ }
|
|
|
|
+ NSString *attachments = [urlArray componentsJoinedByString:@","];
|
|
|
|
+ if (self.chooseFileParm) { // 回调
|
|
|
|
+ [self.chooseFileParm setValue:attachments forKey:@"fileUrl"];
|
|
|
|
+ [self postMessage:self.chooseFileParm];
|
|
|
|
+ self.chooseFileParm = nil;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ [self removehub];
|
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
|
+ }
|
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
|
+ [self removehub];
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#pragma mark --- 上传视频文件
|
|
|
|
+- (void)uploadVideoWithUrl:(NSString *)videoUrl {
|
|
|
|
+ // 取出视频第一帧
|
|
|
|
+ UIImage *previewImage = [self firstFrameWithVideoURL:[NSURL fileURLWithPath:videoUrl] size:CGSizeMake(1280, 720)];
|
|
|
|
+ __block NSString *imageUrl = @"";
|
|
|
|
+ if (previewImage) { // 如果有第一帧
|
|
|
|
+ NSData *imgData = [UIImage turnsImaegDataByImage:previewImage];
|
|
|
|
+ [KSNetworkingManager multiImageUpload:KS_POST imgDataArray:@[imgData] success:^(NSArray * _Nonnull dics) {
|
|
|
|
+ NSDictionary *dic = [dics lastObject];
|
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
|
+ NSDictionary *result = [dic dictionaryValueForKey:@"data"];
|
|
|
|
+ NSString *avatar = [result stringValueForKey:@"url"];
|
|
|
|
+ imageUrl = avatar;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
|
+ }
|
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
|
+
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 上传视频
|
|
|
|
+ [self hudTipWillShow:YES];
|
|
|
|
+ NSData *fileData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:videoUrl]];
|
|
|
|
+ [KSNetworkingManager videoFileUpload:KS_POST fileData:fileData progress:^(int64_t bytesWritten, int64_t totalBytes) {
|
|
|
|
+ dispatch_main_async_safe(^{
|
|
|
|
+ // 显示进度
|
|
|
|
+ if (self.HUD) {
|
|
|
|
+ self.HUD.progress = bytesWritten / totalBytes;// progress是回调进度
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } success:^(NSDictionary * _Nonnull dic) {
|
|
|
|
+ [self hudTipWillShow:NO];
|
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
|
+ NSString *fileUrl = [[dic dictionaryValueForKey:@"data"] stringValueForKey:@"url"];
|
|
|
|
+ [self videoUploadCallback:fileUrl firstFrameImg:imageUrl];
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
|
+ }
|
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
|
+ [self hudTipWillShow:NO];
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)videoUploadCallback:(NSString *)remoteVideoUrl firstFrameImg:(NSString *)imgUrl {
|
|
|
|
+ if (self.chooseFileParm) { // 回调
|
|
|
|
+ [self.chooseFileParm setValue:remoteVideoUrl forKey:@"fileUrl"];
|
|
|
|
+ [self.chooseFileParm setValue:imgUrl forKey:@"firstFrameImg"];
|
|
|
|
+ [self postMessage:self.chooseFileParm];
|
|
|
|
+ self.chooseFileParm = nil;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#pragma mark ---- 获取图片第一帧
|
|
|
|
+- (UIImage *)firstFrameWithVideoURL:(NSURL *)url size:(CGSize)size
|
|
|
|
+{
|
|
|
|
+ // 获取视频第一帧
|
|
|
|
+ NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
|
|
|
|
+ AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:url options:opts];
|
|
|
|
+ AVAssetImageGenerator *generator = [AVAssetImageGenerator assetImageGeneratorWithAsset:urlAsset];
|
|
|
|
+ generator.appliesPreferredTrackTransform = YES;
|
|
|
|
+ generator.maximumSize = CGSizeMake(size.width, size.height);
|
|
|
|
+ NSError *error = nil;
|
|
|
|
+ CGImageRef imgRef = [generator copyCGImageAtTime:CMTimeMake(0, 10) actualTime:NULL error:&error];
|
|
|
|
+ if (imgRef) {
|
|
|
|
+ UIImage *image = [UIImage imageWithCGImage:imgRef];
|
|
|
|
+ CGImageRelease(imgRef);
|
|
|
|
+ return image;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return nil;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#pragma mark ---- UIDocumentPickerDelegate
|
|
|
|
+- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
|
|
|
|
+ NSArray *array = [[url absoluteString] componentsSeparatedByString:@"/"];
|
|
|
|
+ NSString *fileName = [array lastObject];
|
|
|
|
+ fileName = [fileName stringByRemovingPercentEncoding];
|
|
|
|
+
|
|
|
|
+ if (self.fileChooseType == CHOOSETYPE_XML) {
|
|
|
|
+ if (![fileName hasSuffix:@".xml"]) {
|
|
|
|
+ [self MBPShow:@"请上传XML格式文件"];
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if (![fileName hasSuffix:@".mp3"] && ![fileName hasSuffix:@".aac"]) {
|
|
|
|
+ [self MBPShow:@"暂不支持此格式!"];
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取文件大小
|
|
|
|
+// CGFloat fileSize = [self getFileSize:url];
|
|
|
|
+// if (fileSize > 10.0) {
|
|
|
|
+// [self MBPShow:@"文件大小需小于10M"];
|
|
|
|
+// return;
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ __block NSString * fileUrl = @"";
|
|
|
|
+ if ([KSICloudManager iCloudEnable]) {
|
|
|
|
+ [KSICloudManager downloadWithDocumentURL:url callBack:^(id obj) {
|
|
|
|
+ NSData *data = obj;
|
|
|
|
+
|
|
|
|
+ //写入沙盒Documents
|
|
|
|
+ NSString *pathStr = [NSHomeDirectory() stringByAppendingString:[NSString stringWithFormat:@"/Documents/%@",fileName]];
|
|
|
|
+ [data writeToFile:pathStr atomically:YES];
|
|
|
|
+
|
|
|
|
+ if (![[NSFileManager defaultManager] fileExistsAtPath:pathStr]) {
|
|
|
|
+ BOOL isSuccess = [data writeToFile:pathStr atomically:YES];
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ fileUrl = pathStr;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ [self MBPShow:@"写入文件错误!"];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ fileUrl = pathStr;
|
|
|
|
+ }
|
|
|
|
+ [self uploadFile:fileName fileUrl:pathStr];
|
|
|
|
+
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ [self MBPShow:@"iCloud不可用!"];
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)uploadFile:(NSString *)fileName fileUrl:(NSString *)fileUrl {
|
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
+ [self showhud];
|
|
|
|
+ NSString *suffix = [NSString stringWithFormat:@".%@",[[fileName componentsSeparatedByString:@"."] lastObject]];
|
|
|
|
+ NSData *fileData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:fileUrl]];
|
|
|
|
+ [KSNetworkingManager fileUpload:KS_POST fileData:fileData fileSuffix:suffix success:^(NSDictionary * _Nonnull dic) {
|
|
|
|
+ [self removehub];
|
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
|
+ NSString *fileUrl = [[dic dictionaryValueForKey:@"data"] stringValueForKey:@"url"];
|
|
|
|
+ if (self.chooseFileParm) { // 回调
|
|
|
|
+ [self.chooseFileParm setValue:fileUrl forKey:@"fileUrl"];
|
|
|
|
+ [self postMessage:self.chooseFileParm];
|
|
|
|
+ self.chooseFileParm = nil;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
|
+ [self removehub];
|
|
|
|
+ }];
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (CGFloat)getFileSize:(NSURL *)fileUrl {
|
|
|
|
+ NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
|
+ float filesize = -1.0;
|
|
|
|
+ NSString *path = fileUrl.path;
|
|
|
|
+ if ([fileManager fileExistsAtPath:path]) {
|
|
|
|
+ NSDictionary *fileDic = [fileManager attributesOfItemAtPath:path error:nil];//获取文件的属性
|
|
|
|
+ unsigned long long size = [[fileDic objectForKey:NSFileSize] longLongValue];
|
|
|
|
+ filesize = 1.0*size/1024/1024;
|
|
|
|
+ }
|
|
|
|
+ return filesize;
|
|
|
|
+}
|
|
|
|
+
|
|
/*
|
|
/*
|
|
#pragma mark - Navigation
|
|
#pragma mark - Navigation
|
|
|
|
|