1

I am trying to use the category UIProgressView+AFNetworking from AFNetworking UIKit. I have an operation that uploads photos to a server. Mulitple photos at once. But my progress view isn't updating at all.

In my UIProgressView I use

[progressView setProgressWithUploadProgressOfOperation:operation animated:YES];

And my request is:

    AFHTTPRequestOperation *operation =
        [manager POST:url parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
            [formData appendPartWithFileData:imageData name:@"imageFile" fileName:fileName mimeType:[NSString stringWithFormat:@"image/%@",fileMime]];
            NSLog(@"Uploading...");
            [SVProgressHUD showWithStatus:@"Uploading File..."];

        } success:^(AFHTTPRequestOperation *operation, id responseObject) {
            //Success

        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            //Fail
            [manager.operationQueue cancelAllOperations];

        }];
SleepNot
  • 2,982
  • 10
  • 43
  • 72

1 Answers1

0

Try this:

[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead){
        double progress = (double)totalBytesRead / totalBytesExpectedToRead;
        NSLog(@"Progress: %.2f", progress);
        // ...
    }];

I have my own progress bar, so I change its value in the setDownloadProgressBlock block.

Valentin Shamardin
  • 3,569
  • 4
  • 34
  • 51