0
通常の状況では、ダウンロード(ビデオ)ファイルは場所パス(.tmp)の下に保存され、 de eg egate法に従う。NSURLSessionDownloadTask:temファイルが保存される場所を変更する方法
ダウンロードして再生するには、ダウンロードする前にファイルパス(場所)をターゲットパス(destinationURL)に変更するにはどうすればよいですか。
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location
{
NSError *error;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *destinationFileName = downloadTask.originalRequest.URL.lastPathComponent;
NSURL *destinationURL = [self.downloadDirURL URLByAppendingPathComponent:destinationFileName];
if([fileManager fileExistsAtPath:[destinationURL path]])
{
[fileManager removeItemAtURL:destinationURL error:nil];
}
BOOL success = [fileManager moveItemAtURL:location toURL:destinationURL error:&error];
}
私が達成したいのは、ビデオプリロード機能です.cocoahttpserverでビデオをダウンロードして、それをプレーヤーの再生元に設定しますが、私が場所のパスを変更できない場合、私は待つ必要がありますビデオのダウンロードが完了するまで。確かに受け入れられません。 – loveDoudou
これは私の答えで示唆したように、ダウンロードタスクの適切な使用ではありません。 – matt