如何在临时目录中保存图像和录制的文件? [英] How to save images and recorded files in temp directory?

查看:162
本文介绍了如何在临时目录中保存图像和录制的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将来自我的应用程序的相机和视频录制的图片存储在临时目录中的单独文件夹中一段时间​​。当任务完成后,他们将保存到数据库中。

I want to store pictures taken from camera and video recordings from my application in a separate folder in temporary directories for a while. And as the task is being completed, they shall be going to save into the database.

如何保存从相机和相机中拍摄的照片。视频录制文件在临时目录中的单独文件夹中?

How do I save pictures taken from camera & video recording files in a separate folder in temp directories?

推荐答案

您正在寻找这个以获取缓存文件夹以存储临时文件文件:

You are looking for this to get tot he caches folder to store temporary files:

NSString* path = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, 
                                                      NSUserDomainMask,
                                                      YES) lastObject];

从那里你可以使用 NSFileManager 来创建并删除所需的目录。并且存储文件就像文件系统的任何其他部分一样。请注意,系统会立即清除缓存目录。

From there you can use NSFileManager to create and remove the directories you want. And store files just as to any other part of a file system. Just be aware that the system will purge the caches directory now and then.

因此,在重新启动应用之间,永远不要依赖文件剩余,也不要消失。

So never rely on file remaining, nor disappearing, between restarts of your app.

这篇关于如何在临时目录中保存图像和录制的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆