iOS 上传头像
作者:
不知蜕变的挣扎 | 来源:发表于
2017-02-09 15:03 被阅读258次
AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager];
sessionManager.requestSerializer.timeoutInterval = 600;
sessionManager.responseSerializer = [AFJSONResponseSerializer serializer];
[sessionManager POST:KinGuardUploadPhotoApi parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
// 需将image转化为NSData
_headData = UIImageJPEGRepresentation(image, 0.5);
[formData appendPartWithFileData: _headData name:@"HeadImage" fileName:@"KinHeadPortrait.jpg" mimeType:@"image/jpeg"];
} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
finished(responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
failed(error.description);
}];
本文标题:iOS 上传头像
本文链接:https://www.haomeiwen.com/subject/tpgiittx.html
网友评论