简体   繁体   English

如何在应用重新启动/关闭时删除tempDirectory中的数据-Appcelerator Titanium

[英]How to delete data in tempDirectory on app restart/shutdown - Appcelerator Titanium

Part of my app functionalities is allowing user to multi select photos from gallery and then upload them. 我的应用程序功能的一部分是允许用户从图库中选择多个照片,然后上传它们。 Before uploading, user is free to add/delete their photos. 上传之前,用户可以自由添加/删除他们的照片。

What I'm doing is I create and store these temporary image files in Titanium.Filesystem.tempDirectory, with an intention that these will be deleted eventually on app restart or shutdown. 我正在做的是我将这些临时图像文件创建并存储在Titanium.Filesystem.tempDirectory中,目的是在应用程序重新启动或关闭时最终将其删除。

Though, when I use Finder to track these files, they're still there and do not get deleted after I close and reopen the app/reboot ios simulator. 但是,当我使用Finder跟踪这些文件时,它们仍然存在,并且在我关闭并重新打开app / reboot ios模拟器后不会被删除。 So do I have to explicitly delete these files? 那么,我是否必须明确删除这些文件? Does the actual ios device behave any differently? 实际的ios设备的行为是否有所不同?

Thank you 谢谢

Simply the codes where these img files get created: 只需创建这些img文件的代码即可:

var f = Titanium.Filesystem.getFile(Titanium.Filesystem.tempDirectory, fileName);
if (f.write(imageBlob) === false) {
    console.log("Image writing failed");
} 

You can just leave the files there. 您可以将文件保留在那里。 On a device they will be cleaned up when the device needs space. 在设备上,当设备需要空间时,将对其进行清理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM