我想以后台模式发送我的文件但是当我切换到后台上传停止时。但是发送video.i发送视频发布方法没有问题。但是我发送的图像是字符串...
我开始行动的方式
[[AFHTTPRequestOperationManager manager].operationQueue addOperation:requestOperation];
初始化为帖子
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:[NSString stringWithFormat:@"%@%@",API_URL,Upload_Image] parameters:paraDict error:nil];
其他代码:
[requestOperation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
MAINPATCH
double percentDone = (double)totalBytesWritten / (double)totalBytesExpectedToWrite;
NSLog(@"progress updated(percentDone) : %f", percentDone);
progressView2.progress = percentDone;
patchEND
}];
处理
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];