【发布时间】:2016-02-15 19:13:25
【问题描述】:
我需要保护 iOS 上文档目录或(库目录)中的文件,尤其是视频。我不希望用户可以通过 Xcode 或 iExplorer 应用程序下载文档目录中的视频。我需要保护库目录中的私人内容(或)如何在从服务器下载后加密视频文件。请帮我解决这个问题。
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@.mp4",videoUrlName]]];
NSString* path = [NSString stringWithFormat:@"%@.mp4",videoName];
AFDownloadRequestOperation *videoDownloadRequest = [[AFDownloadRequestOperation alloc] initWithRequest:request targetPath:path shouldResume:YES];
[videoDownloadRequest setProgressiveDownloadProgressBlock:^(AFDownloadRequestOperation *operation, NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpected, long long totalBytesReadForFile, long long totalBytesExpectedToReadForFile)
{
float progress = totalBytesReadForFile / (float)totalBytesExpectedToReadForFile;
NSString *progressMessage = [NSString stringWithFormat:@"%@%@ / %@", @"Downloading...", [self fileSizeStringWithSize:totalBytesReadForFile], [self fileSizeStringWithSize:totalBytesExpectedToReadForFile]];
}];
[videoDownloadRequest setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Message" message:[NSString stringWithFormat:@"%@ has been added to your Playlist",detailCellView.titleLabel.text] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alertView show];
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
}];
[[NSOperationQueue mainQueue] addOperation:videoDownloadRequest];
【问题讨论】:
标签: ios objective-c iphone ios7 ios8