iOS ASIHTTPRequest [请求临时文件下载路径];会自动下载文件并删除吗?
我正在尝试通过下载一些图像文件来检查响应时间。 所以我使用 ASIHTTPRequest [请求临时文件下载路径];
它会下载iPhone临时目录中的文件并自动删除它吗?
I am trying to check the response time with downloading some image file..
So I am using ASIHTTPRequest [request temporaryFileDownloadPath];
Will it download file in temp directory in iPhone and erase it automatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
temporaryFileDownloadPath
是下载期间放置文件的位置。下载后,它将从那里复制到downloadDestinationPath
的位置。如果您将downloadDestinationPath
设置为NSTemporaryDirectory()
,那么该文件将在某个时候被系统自动删除。如果您想立即删除文件,只需不要设置
downloadDestinationPath
或temporaryFileDownloadPath
,它将保留在内存中,然后在请求发出时释放超出范围。如果图像太大而无法放入内存,请在某处设置一个downloadDestinationPath
(这并不重要,只要它有效),然后在下载完成后使用 <代码>[[NSFileManager defaultManager]removeItemAtPath:[请求downloadDestinationPath]错误:nil]。向error
参数传入一个NSError*
来检查删除是否遇到错误。The
temporaryFileDownloadPath
is where the file is placed during the download. After the download, it will be copied from there to the location ofdownloadDestinationPath
. If you setdownloadDestinationPath
toNSTemporaryDirectory()
, then the file will be erased by the system automatically at some point.If you want to erase the file straight away though, just don't set a
downloadDestinationPath
or atemporaryFileDownloadPath
, and it will be kept in memory and then deallocated when the request goes out of scope. If the image is too big to fit in memory, set adownloadDestinationPath
somewhere (doesn't really matter, as long as it's valid), and then after the download is finished remove the file from disk using[[NSFileManager defaultManager] removeItemAtPath:[request downloadDestinationPath] error:nil]
. Pass in anNSError*
to theerror
parameter to check if the delete encounters an error.