ios 关于 相册视频路径上传问题

本次测试上传视频的时候,发下从相册调用视频路径:assets-library://asset/asset.m4v?id=D7C196AE-7754-4153-A75A-41523A623F33&ext=m4v是这种格式的,于是乎各种查询资料,

现解决办法: 首先定义路径 沙盒路径:Libary下的目录[[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"polidSaid"]

ALAssetRepresentation *rep = [asset defaultRepresentation];

Byte *buffer = (Byte*)malloc((unsigned long)rep.size);

//流大小

NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:(unsigned long)rep.size error:nil];

//清空视频缓存

NSFileManager* fileManager=[NSFileManager defaultManager];

NSString *createPath =  KVideoUrlPath;

//判断文件是否存在

BOOL blHave=[[NSFileManager defaultManager] fileExistsAtPath:createPath];

if (blHave) {

BOOL blDele= [fileManager removeItemAtPath:createPath error:nil];

if (!blDele) {

[fileManager removeItemAtPath:createPath error:nil];

}

[fileManager removeItemAtPath:createPath error:nil];

}

NSString *namLong= [NSString stringWithFormat:@"%ld.mp4",(unsigned long)buffered];

[self videoWithUrl:urlFile withFileName:namLong];

self.VideoPathUrl = [NSString stringWithFormat:@"%@/%@",KVideoUrlPath,namLong];

thepath:打印输出的就是:/var/mobile/Containers/Data/Application/xxxxx/路径格式/xxx.mp4。

有更好解决assets-library://asset/asset.m4v?id=D7C196AE-7754-4153-A75A-41523A623F33&ext=m4v
这种路径问题办法的可以相互交流

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 昨天一天下午还真是个种查,各种搜索,然后各种技术群,各种问,(没人鸟我),其实我是有这个能力的,怎么就一上...
    梦随兴飞阅读 25,149评论 7 18
  • iOS开发-文件管理(一) 一、iOS中的沙盒机制 iOS应用程序只能对自己创建的文件系统读取文件,这个独立、封闭...
    Friez平板支撑阅读 4,647评论 0 1
  • 27、ViewController的didReceiveMemoryWarning是在什么时候调用的?默认的操作是...
    烟雨平生花飞舞阅读 633评论 0 1
  • //获得应用程序沙盒的Documents文件夹路径** NSArray *arrDocumentPaths = N...
    博行天下阅读 489评论 2 1
  • 每个iOS应用都有自己的应用沙盒(应用沙盒就是文件系统目录),与其他文件系统隔离。应用必须待在自己的沙盒里,其他应...
    彬至睢阳阅读 721评论 0 0