最近发现插件分享文件(文件或者视频)超过120M时,插件崩溃,于是到处找办法,哈哈,终于解决!!!
下面是分享代码:
//文件路径
NSString* filePath =@"";
//获取文件原始路径
NSRange fromRange = [fileURL.absoluteString rangeOfString:@"/var"];//文件路径需要移除/var之前路径
NSString *fromPath = [fileURL.absoluteString substringFromIndex:fromRange.location].stringByRemovingPercentEncoding;
//文件拷贝路径
NSString *decodeFilePath = [fileURL.absoluteString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *path = [APPDOCPATH stringByAppendingPathComponent:[decodeFilePath lastPathComponent]];
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
filePath = path;
}else{
NSError*copyError;
BOOLret = [[NSFileManager defaultManager] copyItemAtPath:fromPath toPath:path error:&Error];
if(ret) {
filePath = path;
}else{
if(copyError !=nil) {
NSLog(@"复制出错啦 = %@",copyError);
}
}
}