AFNetworking Uploading a file

时光怂恿深爱的人放手 提交于 2019-11-27 12:29:07

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!