ASIFormDataRequest upload progress is not accurate

101 views Asked by At

Iam using ASIFormDataRequest for uploading and downloading. The download progress is very accurate and finished when the download finish, but the upload progress jumps from 0 to 1 rapidly even the upload didnt finish yet. Below the upload request and download request

Upload request:

uploadRequest = [[ASIFormDataRequest alloc]initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/ImageBUP.aspx",ZsafeapiURL]] :@"POST"];
                [uploadRequest setTag:i];
                [uploadRequest setDelegate:self];
                [uploadRequest setPostFormat:ASIMultipartFormDataPostFormat];
                [uploadRequest setUploadProgressDelegate:[self.progressBarArray objectAtIndex:i]];
                [uploadRequest setShowAccurateProgress:YES];
                [uploadRequest setData:[[self.dataToUpload objectAtIndex:i]valueForKey:@"data"] forKey:nil] ;
                [uploadRequest addRequestHeader:@"UserID" value:[[NSUserDefaults standardUserDefaults] objectForKey:@"userID"]];
                [uploadRequest addRequestHeader:@"Handsettype" value:@"3"];
                [uploadRequest addRequestHeader:@"ImageName" value:imageName];
                [uploadRequest addRequestHeader:@"ImagePath" value:@"0"];
                [uploadRequest addRequestHeader:@"Desc" value:[[NSUserDefaults standardUserDefaults] objectForKey:@"platform"]];
                [uploadRequest addRequestHeader:@"Extension" value:[[self.dataToUpload objectAtIndex:i]valueForKey:@"extension"]];
                [uploadRequest addRequestHeader:@"Size" value:[[self.dataToUpload objectAtIndex:i]valueForKey:@"sizeInByte"]];
                [uploadRequest setShouldContinueWhenAppEntersBackground:YES];
                [uploadRequest setTimeOutSeconds:500];
                [myQueue addOperation:uploadRequest];


Download request:

      NSString *videoURL=[[self.dataToUpload objectAtIndex:i]valueForKey:@"videoURL"];
                NSString *videoOriginalName=[[self.dataToUpload objectAtIndex:i]valueForKey:@"name"];

                NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
                NSString *folderPath = [documentsDirectory stringByAppendingPathComponent:@"/Videos"];

                if (![[NSFileManager defaultManager] fileExistsAtPath:folderPath])
                    [[NSFileManager defaultManager] createDirectoryAtPath:folderPath withIntermediateDirectories:NO attributes:nil error:nil];
                NSString *videoPathInApp=[folderPath stringByAppendingPathComponent:videoOriginalName];


                downloadRequest = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:videoURL] :@"GET"];
                [downloadRequest setDelegate:self];
                [downloadRequest setDownloadDestinationPath:videoPathInApp];
                [downloadRequest setDownloadProgressDelegate:[self.progressBarArray objectAtIndex:i]];
                [downloadRequest setTag:i];
                [downloadRequest setShowAccurateProgress:YES];
                [myQueue addOperation:downloadRequest];

am I missing anything ?

0

There are 0 answers