【问题标题】:how to check if a file ( video) is already in ALAssetsLibrary (photo album ) before saving it?如何在保存之前检查文件(视频)是否已经在 ALAssetsLibrary(相册)中?
【发布时间】:2012-03-20 09:58:06
【问题描述】:

我正在将文件从服务器保存到 ALAssetLibrary,以便用户可以在离线模式下查看它

但是我不希望用户多次下载单个文件以避免在相册应用程序中创建重复文件。

这是我的代码:

    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 ];
    }

【问题讨论】:

标签: iphone ios ipad alassetslibrary


【解决方案1】:

我认为你不能。您可以使用许多算法来比较 SHA-1、MD5、CRC 等文件。但是在ALAsset 的情况下,所有提到的都会失败。

因为,每当您使用ALAsset 将文件保存到Photo-Library 时,它都会将位置、时间等.. 信息与文件一起存储。所以同一个文件对应的保存过程会有所不同。

以上所有算法都是针对文件竞争的。所以在ALAsset的情况下它们都会失败

【讨论】:

    猜你喜欢
    • 2019-09-27
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-21
    • 1970-01-01
    • 2013-10-28
    相关资源
    最近更新 更多