Does any one have a full implementation of uploading a file using AFNetworking. I have found some code on the internet but it is incomplete. The code I have found is here:
First, make sure you have the latest version of AFNetworking downloaded.
AFHTTPRequestOperation +HTTPRequestOperationWithRequest:success:failure:
was removed a few versions back. Instead, you can do [[AFHTTPRequestOperation alloc] initWithRequest:...]
and then set the completionBlock
with either the straight property accessor (operation.completionBlock = ^{...}
), or with -setCompletionBlockWithSuccess:failure:
. Keep in mind that completion blocks execute after the request has finished downloading.
As for the multipart form block, -appendWithFileData:mimeType:name
was also removed a while back. The method you want is -appendPartWithFileData:name:fileName:mimeType:
.
Make those two changes and everything should work.