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 8150619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:07:15+00:00 2026-06-06T15:07:15+00:00

Man, stumped on this one. Trying to download a file with AFNetworking and the

  • 0

Man, stumped on this one. Trying to download a file with AFNetworking and the best I can do is capture the progress bytes in the downloadProgressBlock. I’ve tried many different forks of AFNetworking and now I’m back to the latest build. Looks like at one time the AFHTTPRequestOperation was modified to also include NSURLResponse but that’s gone in the latest release. And, per the code below, the “success” block is never called. I get a log of the downloaded bytes and then ^complete is called. success and error are never called.

Any guidance on this would be awesome. I can’t figure out where the data is returned and how to get it to use NSFileManager on it? I need to download files, not write streams for images, etc.

Edit: I’ve also tried to capture the data by overriding – (void)connection:didReceiveData as suggested in the documentation but nothing doing there.

// url is http://mydomain.com/somezip.zip

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", url]]];

AFHTTPRequestOperation *operation = [AFHTTPRequestOperation HTTPRequestOperationWithRequest:request success:^(id object) {

    NSLog(@"hey, some success!");

} failure:^(NSHTTPURLResponse *response, NSError *error) {

    NSLog(@"%@", error);

}];


[operation setDownloadProgressBlock:^(NSInteger bytesRead, NSInteger totalBytesRead, NSInteger totalBytesExpectedToRead) {

    // callback is sent in and works great.  Just outputting to the console at the moment
    SEL callme = NSSelectorFromString(callback);
    [sender performSelectorOnMainThread:callme withObject:[NSNumber numberWithInt:bytesRead] waitUntilDone:NO];

}];

[operation setCompletionBlock:^{
    NSLog(@"operation complete");
}];

NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
[queue addOperation:operation];
  • 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-06-06T15:07:18+00:00Added an answer on June 6, 2026 at 3:07 pm

    You can simply use this feature that is included on AFNetworking and even save it to disk –
    Notice the operation.outputStream:

    NSMutableURLRequest* rq = [api requestWithMethod:@"GET" path:@"YOUR/URL/TO/FILE" parameters:nil];
    AFHTTPRequestOperation *operation = [[[AFHTTPRequestOperation alloc] initWithRequest:rq] autorelease];
    
    NSString* path=[@"/PATH/TO/APP" stringByAppendingPathComponent: imageNameToDisk];
    operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];
    
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    
        NSLog(@"SUCCCESSFULL IMG RETRIEVE to %@!",path)
    
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    
        // Deal with failure
    }];
    

    EDIT : missed

    [operation start]; 
    

    EDIT : ...or if you use an AFHTTPClient * apiClient :

    // [apiClient enqueueHTTPRequestOperation:operation];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading the Bash man pages and with respect to this post , I
I've tried man(3) setsid , but it only explains how to use it, I
I am a one-man shop at the place where I work, and when I
Man, this is getting frustrating! In Laravel 4, using Eloquent, this works: var_dump(Worker::find(1)); .
man gitglossary contains this definition of an evil merge : An evil merge is
Man, is my stack overflowing! I've tried about four times to install MySQL in
I'm a one man developer PHP/MySQL developer. The contents of our database come an
want to implement poor man's ssl only to encrypt certain fields of only one
Man, I just had this project given to me - expand on this they
I have a poor man's replication setup that I can't do anything about. Some

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.