ASIFileManagementError是什么意思?

凯西

我正在使用ASI下载文件,并且一直看到ASIFileManagementError我猜这意味着我为请求构建下载路径的方式有问题,但是不一致。有时下载工作正常,而其他时候下载失败。即使在同一设备上使用相同代码下载相同文件时!这是我的代码。

-(ASIHTTPRequest*)buildDownloadLinkForUpdate:(ContentItem*)update
{
    NSString *URLString = [[NSString alloc] initWithFormat:@"%@?%@=%@", update.downloadUrl.absoluteString, @"auth_token", database.userAuthToken];
    NSURL *url = [NSURL URLWithString:URLString];

    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setRequestMethod:@"GET"];

    ContentItem* item = [database getItemWithId:update.uniqueId];
    [request setDownloadDestinationPath:item.contentPath];
    [request setTemporaryFileDownloadPath:[[AppSettings instance].temporaryPath stringByAppendingPathComponent:item.fileName]];
    [request setAllowResumeForFileDownloads:TRUE];
    [request setShowAccurateProgress: TRUE];
    [request setDelegate:[_currentItem progressDelegate]];

    return request;
}

-(void)initalizeNetworkQueue
{
    if(!networkQueue) networkQueue = [[ASINetworkQueue alloc] init];

    [networkQueue cancelAllOperations];
    [networkQueue reset];

    if([_currentItem progressDelegate])
    {
        [networkQueue setDownloadProgressDelegate:[_currentItem progressDelegate]];
    }

    [networkQueue setDelegate:self];
    [networkQueue setRequestDidFinishSelector:@selector(networkQueueComplete:)];
    [networkQueue setRequestDidFailSelector:@selector(networkQueueFailed:)];
    [networkQueue setShowAccurateProgress:YES];
    networkQueue.maxConcurrentOperationCount = 1;
}

然后是实际调用此代码的代码:

[self initalizeNetworkQueue];
[networkQueue addOperation:[self buildDownloadLinkForUpdate:_currentUpdate]];
[networkQueue go];
currentState = ContentUpdaterStateDownloading;

这里显然有什么问题吗?

-=更新=-表示失败,因为它无法将文件从临时位置移动到最终位置。

Download Failed: Failed to move file from '/var/mobile/Applications/33E1DF3C-17F5-432F-8204-A9B53AB5AAE3/Documents/.temp/FileShare+Gate+4.pptx' to '/var/mobile/Applications/33E1DF3C-17F5-432F-8204-A9B53AB5AAE3/Documents/.content/FileShare+Gate+4.pptx'

塔雷克·哈拉克(Tarek Hallak)

我之前有此错误,它在连接中,它是类型ASINetworkErrorType,这意味着无法访问主机。

无论如何ASIHttprequest现在已经死了,您将无法找到许多问题的答案,请采纳我的建议,并使用AFNetworking,这很不错,并且可以胜任。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章