Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7589915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:16:48+00:00 2026-05-30T20:16:48+00:00

I’m downloading mp3 files from Rackspace cloud files, and for large files i’m encountering

  • 0

I’m downloading mp3 files from Rackspace cloud files, and for large files i’m encountering an issue where the download is completed successfully but the file is not yet downloaded completely. For example, a 40 MB mp3 file (01:00:00 duration) is download as as 4.5 MB mp3 file (00:10:30 duration). This doesn’t happen all the time.

  1. Any pointers as to what’s going on?
  2. Why is this happening, and how can i fix this issue?
  3. How can i build a simple checksum logic to check if the file was downloaded completely?

Here’s how i create and send an async request:

ASIHTTPRequest *request;
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:urlString]];
[request setShouldAttemptPersistentConnection:NO]; 
[request setAllowResumeForFileDownloads:YES];
[request setDownloadProgressDelegate:self];
[request setShouldContinueWhenAppEntersBackground:YES];
[request setUserInfo:userInfo];
[request setDownloadDestinationPath:downloadPath];
[request setTemporaryFileDownloadPath:[NSString stringWithFormat:@"%@.download", downloadPath]];

[self.networkQueue addOperation:request];
[self.networkQueue go];

Note i’m using a network queue with 4 concurrent downloads.

Thanks.

Edit (Mon March 5, 2012, 03:25 PM)

So, further investigation shows that ASINetworkQueue is calling requestDidFinishSelector delegate method instead of requestDidFailSelector. The status code returned by the ASIHTTPRequest object is 206, HTTP/1.1 206 Partial Content in requestDidFinishSelector method. The status code should be 200, HTTP/1.1 200 OK.

I still don’t know why! and i still don’t know how to fix this. It seems that i’ll have to delete the partially downloaded file and start the download process again. At this point the temporary file i.e. %@.download is removed, and this partially downloaded file is put at the destination path.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:16:49+00:00Added an answer on May 30, 2026 at 8:16 pm

    So, this is what i ended up doing, and hopefully this’ll be enough (to solve the problem).

    Here’s how i’m creating the network queue:

    - (ASINetworkQueue *)networkQueue {
    
        if (!_networkQueue) {
            _networkQueue = [[ASINetworkQueue alloc] init];
            [_networkQueue setShowAccurateProgress:YES];
            [_networkQueue setRequestDidFinishSelector:@selector(contentRequestDidSucceed:)];
            [_networkQueue setRequestDidFailSelector:@selector(contentRequestDidFail:)];
            [_networkQueue setShouldCancelAllRequestsOnFailure:NO];
            [_networkQueue setDelegate:self];
        }
    
        return _networkQueue;
    }
    

    And here’s what my contentRequestDidSucceed: method does:

    - (void)contentRequestDidSucceed:(ASIHTTPRequest *)request {
        // ASIHTTPRequest doesn't use HTTP status codes (except for redirection), 
        // so it's up to us to look out for problems (ex: 404) in the requestDidFinishSelector selector. 
        // requestDidFailSelector will be called only if there is the server can not be reached 
        // (time out, no connection, connection interrupted, ...)
    
        // In certain cases ASIHTTPRequest/ASINetworkQueue calls the delegate method requestDidFinishSelector,
        // instead it should call requestDidFailSelector. I've encountered this specific case with status code 206 (HTTP/1.1 206 Partial Content). In this case the file was not completely downloaded, so we'll have to re-process the request.
        if ([request responseStatusCode] != 200) {
            NSLog(@" ");
            NSLog(@"======= BEEP =======");
            NSLog(@" ");
    
            // We're double checking that the file was indeed not downloaded completely!
            // During internal testing, we encountered a case where download was successful
            // but we received 206 as the response code (maybe we received the cached value).
            unsigned long long progress = [request totalBytesRead] + [request partialDownloadSize];
            unsigned long long total = [request contentLength] + [request partialDownloadSize];
    
            if (progress != total) {
                NSString *downloadPath = [request downloadDestinationPath];
                NSString *temporaryDownloadPath = [self temporaryPathForFile:downloadPath];
    
                // Move the file at destination path to the temporary destination path (back again)    
                NSError *moveError = nil;
                [[[[NSFileManager alloc] init] autorelease] moveItemAtPath:downloadPath 
                                                                    toPath:temporaryDownloadPath 
                                                                     error:&moveError];
    
                if (moveError) {
                    NSLog(@"Failed to move file from '%@' to '%@'", downloadPath, temporaryDownloadPath);
    
                    NSError *removeError = nil;
                    [ASIHTTPRequest removeFileAtPath:downloadPath error:&removeError];
    
                    if (removeError) {
                        NSLog(@"Failed to remove file from '%@'", downloadPath);
                    }
                }
    
                // Call the requestDidFailSelector method
                [self contentRequestDidFail:request];
    
                // Don't continue
                return;   
            }        
        }
    
        // TODO: Process successful request!
        // . . .
    }
    

    If there’s a better way to handle this, please let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.