我应该从 CameraCaptureUI 中删除 StorageFile
Should I remove StorageFile from CameraCaptureUI
我正在创建一个通用应用程序来捕获照片或视频并通过其 REST API 将其上传到 SharePoint。当前原型的流程很简单:
- 在主页上,用户点击按钮拍摄照片或视频
- 可以使用 CameraCaptureUI 拍摄照片或视频API
- 用户被重定向到 he/she 可以输入一些元数据的页面
- 如果用户单击上传按钮,文件将发送到 SharePoint,用户将返回主页
- 如果用户点击取消按钮,he/she 被发送回主页
所有这些都有效,但我不确定在不再需要 StorageFile 后如何处理它。在 phone 上,文件保存到某个默认位置。我不是复制到图片库什么的,文件上传后(或用户取消)我不再需要它在设备上。
我应该自己删除这个 StorageFile 还是 OS 在应用程序暂停或关闭时处理这个问题?我想避免应用程序随着时间的推移慢慢占用越来越多的存储空间 space,例如因为用户在上传文件之前关闭它。
附带说明:我没有使用后台任务来上传文件。用户需要监控上传(进度条),失败重试。如果因为没有互联网连接或因为 SharePoint 关闭而无法上传文件,我不再关心它。
一切都取决于您存储文件的位置。如果您为此使用了本地文件夹,那么删除该文件可能是一个不错的选择,因为它不会再占用内存。
尽管如此,根据我的阅读,您的场景只适合临时位置。如果你使用 ApplicationData.TemporaryFolder then you don't need to take care of the file as the OS will handle it when needed:
The temporary app data store works like a cache. Its files do not roam and could be removed at any time. The System Maintenance task can automatically delete data stored at this location at any time. The user can also clear files from the temporary data store using Disk Cleanup. Temporary app data can be used for storing temporary information during an app session. There is no guarantee that this data will persist beyond the end of the app session as the system might reclaim the used space if needed.
我正在创建一个通用应用程序来捕获照片或视频并通过其 REST API 将其上传到 SharePoint。当前原型的流程很简单:
- 在主页上,用户点击按钮拍摄照片或视频
- 可以使用 CameraCaptureUI 拍摄照片或视频API
- 用户被重定向到 he/she 可以输入一些元数据的页面
- 如果用户单击上传按钮,文件将发送到 SharePoint,用户将返回主页
- 如果用户点击取消按钮,he/she 被发送回主页
所有这些都有效,但我不确定在不再需要 StorageFile 后如何处理它。在 phone 上,文件保存到某个默认位置。我不是复制到图片库什么的,文件上传后(或用户取消)我不再需要它在设备上。
我应该自己删除这个 StorageFile 还是 OS 在应用程序暂停或关闭时处理这个问题?我想避免应用程序随着时间的推移慢慢占用越来越多的存储空间 space,例如因为用户在上传文件之前关闭它。
附带说明:我没有使用后台任务来上传文件。用户需要监控上传(进度条),失败重试。如果因为没有互联网连接或因为 SharePoint 关闭而无法上传文件,我不再关心它。
一切都取决于您存储文件的位置。如果您为此使用了本地文件夹,那么删除该文件可能是一个不错的选择,因为它不会再占用内存。
尽管如此,根据我的阅读,您的场景只适合临时位置。如果你使用 ApplicationData.TemporaryFolder then you don't need to take care of the file as the OS will handle it when needed:
The temporary app data store works like a cache. Its files do not roam and could be removed at any time. The System Maintenance task can automatically delete data stored at this location at any time. The user can also clear files from the temporary data store using Disk Cleanup. Temporary app data can be used for storing temporary information during an app session. There is no guarantee that this data will persist beyond the end of the app session as the system might reclaim the used space if needed.