iphoneobjective-cuiprogressviewasiformdatarequest

How to show UIProgressView with ASIFormDataRequest


I want to show uiprogress bar with ASIFormDataRequest. I googled it but i can't find regarding uiprogressView with ASIFormDataRequest, I just find uiprogressView with NSURLConnection. just let me know if it is possible.

// So this my method where i upload the data.

-(NSMutableArray*)getUploadVideo:(NSString*)titleName userID:(NSString*)userId token:(NSString*)tokenID description:(NSString*)desc videoID:(NSString*)video_id privateOrPublic:(NSString*)privacyID pathOfVideoFile:(NSString*)path mode:(NSString*)potLand;
{

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://%@/aircastdev/RestServices/fileUpload"],kId];

[request setDelegate:self];

[request setDidFailSelector:@selector(uploadFailed:)];

[request setDidFinishSelector:@selector(uploadFinished:)];

[request setDidFinishSelector:@selector(requestFailed:)];
[request setDidFinishSelector:@selector(requestFinished:)];


[request setPostValue:titleName forKey:@"title"];
[request setPostValue:userId forKey:@"user_id"]; 
[request setPostValue:tokenID forKey:@"token"]; 
[request setPostValue:desc forKey:@"desc"]; 
[request setPostValue:video_id forKey:@"video_id"]; 
[request setPostValue:privacyID forKey:@"is_private"];
[request setPostValue:potLand forKey:@"mode"];

NSString *url = [[NSURL fileURLWithPath:path] path];

[request setFile:url withFileName:[NSString stringWithFormat:@"%@.mov",titleName] andContentType:@"video/MOV" forKey:@"file"];

[request setTimeOutSeconds:50000];
[request setRequestMethod:@"POST"];
// EDITED LINE

[request setUploadProgressDelegate:myProgressView];

[request startSynchronous];

SBJSON *sbJason = [[SBJSON alloc] init];

getUploadArray = [sbJason objectWithString:self.response];

return getUploadArray;


}

// when upload is done this method call.

- (void)requestFinished:(ASIHTTPRequest *)request
{
// alert: request is successfully sent

 self.response = [request responseString]; //stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];


}

Solution

  • use this:

    [request setDownloadProgressDelegate:progressView];
    

    or

    [request setUploadProgressDelegate:myProgressIndicator];
    

    Where progressView is a UIProgressView also have a look here