Using NSOperationQueue to upload multiple files to server.
//Class B
While uploading multiple files to server at the time move to popviewcontroller (class A). App suddenly crashed. Is there any way to uploading a files to server without interrupt.
Thanks in Advance
//Class B
-(void)UploadtoS3
{
// Convert file to data from locapathfile here
NSData* imgData = [NSData dataWithContentsOfFile:localFilePath]; //VIDEO FILEPATH OR IMAGEPATH
if(![self upload_NetworkQueue]) // If Queue is not initialized
{
[[self upload_NetworkQueue] cancelAllOperations];
[self setUpload_NetworkQueue:[ASINetworkQueue queue]];
[[self upload_NetworkQueue] setDelegate:self];
[[self upload_NetworkQueue] setRequestDidFailSelector:@selector(upload_RequestFailed:)];
[[self upload_NetworkQueue] setQueueDidFinishSelector:@selector(upload_RequestDone:)];
[[self upload_NetworkQueue] setShowAccurateProgress:YES];
[[self upload_NetworkQueue] setMaxConcurrentOperationCount:1];
}
NSString *s3keyPath = [NSString stringWithFormat:@"/test123/%@",fileName];
NSLog(@"UPLOAD IMAGE S3 FILE NAME ----------- %@",s3keyPath);
request = [ASIS3ObjectRequest PUTRequestForData:imgData withBucket:testBuck key:s3keyPath];
[request setSecretAccessKey:s3SecretKey];
[request setAccessKey:s3AccessKey];
[request setTimeOutSeconds:20];
[request setDelegate:self];
[request setNumberOfTimesToRetryOnTimeout:3];
[request setMimeType:mimeType];
[request setUploadProgressDelegate:self];
[[self upload_NetworkQueue] addOperation:request];
[[self upload_NetworkQueue] go];
}