- Add Upload Avatar
This commit is contained in:
1 parent
538b944026
commit
f570c107c9
14 files changed
+1105
-953
No files matched your search
@@ -82,6 +82,42 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ (void) POSTWithEndpointAction:(NSString * _Nonnull) endPoint
|
||||
formData:(NSArray * _Nullable) postFormData
|
||||
parameters:(NSDictionary * _Nullable) parameters
|
||||
progress:(nullable void (^)(NSProgress * _Nonnull uploadProgress)) uploadProgress
|
||||
success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure {
|
||||
|
||||
if ([[PNObjectConfig sharedInstance] currentOauthCredential] && ![[[PNObjectConfig sharedInstance] currentOauthCredential] isExpired]) {
|
||||
|
||||
[[[PNObjectConfig sharedInstance] manager] POST:[[[PNObjectConfig sharedInstance] baseUrl] stringByAppendingFormat:@"%@",endPoint]
|
||||
parameters:parameters
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
|
||||
if (postFormData) {
|
||||
for (PNObjectFormData *postData in postFormData) {
|
||||
|
||||
[formData appendPartWithFileData:[postData formData] name:[postData name] fileName:[postData fileName] mimeType:[postData mimeType]];
|
||||
}
|
||||
}
|
||||
}
|
||||
progress:uploadProgress
|
||||
success:success
|
||||
failure:failure];
|
||||
}
|
||||
else {
|
||||
[[PNObjectConfig sharedInstance] refreshTokenForClientCredentialWithBlockSuccess:^(BOOL refreshSuccess) {
|
||||
|
||||
[self POSTWithEndpointAction:endPoint parameters:parameters progress:uploadProgress success:success failure:failure];
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
|
||||
if (failure) {
|
||||
failure(nil,error);
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Private Methods
|
||||
|
||||
|
||||
Reference in new issue
Block a user