Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

获取视频的沙盒outputPath路径,之后用这个路径oss上传出现找不到视频文件的提示 #1649

Closed
SUWW opened this issue Aug 19, 2023 · 1 comment

Comments

@SUWW
Copy link

SUWW commented Aug 19, 2023

咨询前必看
请先回答下列三个问题,否则不允处理,谢谢配合。
1、我最新的Demo是否有这个bug?【如果Demo没问题,请升级新版
答:暂无发现

2、你用的是什么版本?升级到最新版后是否正常?
答:最新版本

3、是否有改动过我库内部的代码?【如有,请说明改动点
答:无

详情:
我是在聊天中应用到,当选择完成视频后得到outputPath

[[TZImageManager manager] getVideoOutputPathWithAsset:asset presetName:AVAssetExportPresetMediumQuality success:^(NSString *outputPath) {
    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:outputPath] options:nil];
    NSURL *url = asset.URL;
    NSLog(@"选择的视频路径==%@",url);


    
} failure:^(NSString *errorMessage, NSError *error) {
    
}];

获得路径之后,上传,这个是没问题的,可以上传成功的。
但是因为聊天中有时候会发送消息失败的,当失败的时候我会把路径保存起来,路径例如:
/var/mobile/Containers/Data/Application/B866C71C-8309-4ECB-82DE-C1F7628B401F/tmp/video-2023-08-19-18-55-29-611-595429.mp4

当我重新发送消息的时候,我会使用这个路径再去上传,但是就是在这里出现问题,再次使用这个地址上传视频时,阿里的oss报找不到此文件了。请问这个怎么处理?

@banchichen
Copy link
Owner

getVideoOutputPathWithAsset返回的outputPath,是沙盒的tmp目录,这个目录下的内容,应用重启后会被清除
image

绝大部分情况,这个视频选好后,是上传到服务端,不应该长期占据手机磁盘空间,所以我这里使用的tmp目录
如果要长期有效,可以考虑把这个文件,拷贝到Library/Caches里,但这里也不强保障,当手机的存储空间不足时,系统可能会清理

真的要强保障路径长期有效,就要存到Documents目录,这样的话,用户选的视频多了后,你的APP占用空间会比较大,最好要主动清除

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants