iOS ASIHTTPRequest [request temporaryFileDownloadPath]; will download file and erase automatically?
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 d开发者_StackOverflow社区irectory in iPhone and erase it automatically?
The temporaryFileDownloadPath
is where the file is placed during the download. After the download, it will be copied from there to the location of downloadDestinationPath
. If you set downloadDestinationPath
to NSTemporaryDirectory()
, 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 a temporaryFileDownloadPath
, 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 a downloadDestinationPath
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 an NSError*
to the error
parameter to check if the delete encounters an error.
精彩评论