I'm saving a file from a server to ALAssetLibrary so that the user can view it in offline mode
however i don't want the user to download a single file multiple times to avoid creating duplicates in the photo album application.
that's my code :
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
void (^completionBlock)(NSURL *, NSError *) = ^(NSURL *assetURL, NSError *error)
{
if ( error != nil )
{
//writeFailed = YES;
NSLog(@"error = %@", error);
}
//[self notifyCompletionTarget];
NSLog(@" saving is done");
};
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
[library writeVideoAtPathToSavedPhotosAlbum:url completionBlock:completionBlock ];
}
I think You Cant . You can use many algorithms to compare the files like SHA-1, MD5,CRC etc . However in the case of ALAsset
, the mentioned all will fail.
Because , Whenever you are saving a file to Photo-Library
using ALAsset
, it will store the location, time,etc .. information's with the file. So the same file contend will be different corresponding to the save process .
The all above algorithms are regarding to the file contend.So they all will fail in the case of ALAsset
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.