- Add Upload Avatar
This commit is contained in:
parent
538b944026
commit
f570c107c9
@ -40,7 +40,7 @@ PODS:
|
||||
- NSString-Helper (1.0.2)
|
||||
- nv-ios-http-status (0.0.1)
|
||||
- PEAR-FileManager-iOS (1.3.1)
|
||||
- PNObject (0.3.7):
|
||||
- PNObject (0.3.8):
|
||||
- AFNetworking
|
||||
- CodFis-Helper
|
||||
- FBSDKCoreKit
|
||||
@ -96,7 +96,7 @@ SPEC CHECKSUMS:
|
||||
NSString-Helper: 0ee74919829a332f9838fa87b28cb2d1d991e92c
|
||||
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
|
||||
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
|
||||
PNObject: d71bf835bf4ca94308b9764b3c7e7a101d01343a
|
||||
PNObject: f2ff42ecb60a86983e76d460a478b15a5c57d9cf
|
||||
PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb
|
||||
RNCryptor: 59d6483908115af5c12b884db23392024e52a5fe
|
||||
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "PNObject",
|
||||
"version": "0.3.7",
|
||||
"version": "0.3.8",
|
||||
"summary": "PNObject is a simple replica of the more complex ParseObject",
|
||||
"homepage": "https://github.com/giuseppenucifora/PNObject",
|
||||
"license": "MIT",
|
||||
@ -9,7 +9,7 @@
|
||||
},
|
||||
"source": {
|
||||
"git": "https://github.com/giuseppenucifora/PNObject.git",
|
||||
"tag": "0.3.7"
|
||||
"tag": "0.3.8"
|
||||
},
|
||||
"platforms": {
|
||||
"ios": "7.0"
|
||||
|
||||
4
Example/Pods/Manifest.lock
generated
4
Example/Pods/Manifest.lock
generated
@ -40,7 +40,7 @@ PODS:
|
||||
- NSString-Helper (1.0.2)
|
||||
- nv-ios-http-status (0.0.1)
|
||||
- PEAR-FileManager-iOS (1.3.1)
|
||||
- PNObject (0.3.7):
|
||||
- PNObject (0.3.8):
|
||||
- AFNetworking
|
||||
- CodFis-Helper
|
||||
- FBSDKCoreKit
|
||||
@ -96,7 +96,7 @@ SPEC CHECKSUMS:
|
||||
NSString-Helper: 0ee74919829a332f9838fa87b28cb2d1d991e92c
|
||||
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
|
||||
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
|
||||
PNObject: d71bf835bf4ca94308b9764b3c7e7a101d01343a
|
||||
PNObject: f2ff42ecb60a86983e76d460a478b15a5c57d9cf
|
||||
PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb
|
||||
RNCryptor: 59d6483908115af5c12b884db23392024e52a5fe
|
||||
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
|
||||
|
||||
1894
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
1894
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,7 @@
|
||||
buildForArchiving = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = 'primary'
|
||||
BlueprintIdentifier = 'FF6DB175E269D4B6BC28013A2E0B79DC'
|
||||
BlueprintIdentifier = 'FB7B8B19AE1F5E597E5C759195549ABD'
|
||||
BlueprintName = 'PNObject'
|
||||
ReferencedContainer = 'container:Pods.xcodeproj'
|
||||
BuildableName = 'PNObject.framework'>
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.3.7</string>
|
||||
<string>0.3.8</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.3.7</string>
|
||||
<string>0.3.8</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "PNObject"
|
||||
s.version = "0.3.8"
|
||||
s.version = "0.3.9"
|
||||
s.summary = "PNObject is a simple replica of the more complex ParseObject"
|
||||
|
||||
# This description is used to generate tags and improve search results.
|
||||
|
||||
@ -108,6 +108,10 @@
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (strong, nonatomic, nullable) NSString * lastName;
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) NSURL * profileImageUrl;
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
|
||||
@ -301,7 +301,7 @@ static bool isFirstAccess = YES;
|
||||
@"userId":@"uuid",
|
||||
@"firstName":@"first_name",
|
||||
@"lastName":@"last_name",
|
||||
@"profileImage":@"profile_image",
|
||||
@"profileImageUrl":@"profile_image",
|
||||
@"sex":@"sex",
|
||||
@"birthDate":@"birth_year",
|
||||
@"phone":@"phone",
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "PNObject.h"
|
||||
#import "PNObjectFormData.h"
|
||||
|
||||
@interface PNObject (PNObjectConnection)
|
||||
|
||||
@ -22,6 +23,13 @@
|
||||
success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success
|
||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||
|
||||
+ (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;
|
||||
|
||||
+ (id _Nonnull) parseObjectFromResponse:(id _Nullable) response;
|
||||
|
||||
@end
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
54
Pod/Classes/PNObjectFormData.h
Normal file
54
Pod/Classes/PNObjectFormData.h
Normal file
@ -0,0 +1,54 @@
|
||||
//
|
||||
// PNObjectFormData.h
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 16/02/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface PNObjectFormData : NSObject
|
||||
|
||||
@property (nonatomic, strong, nonnull) NSData *formData;
|
||||
@property (nonatomic, strong, nonnull) NSString * name;
|
||||
@property (nonatomic, strong, nonnull) NSString * fileName;
|
||||
@property (nonatomic, strong, nonnull) NSString * mimeType;
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*
|
||||
* @param formData <#formData description#>
|
||||
* @param name <#name description#>
|
||||
* @param fileName <#fileName description#>
|
||||
* @param mimeType <#mimeType description#>
|
||||
*
|
||||
* @return <#return value description#>
|
||||
*/
|
||||
+ (instancetype _Nonnull) formDataFromNSData:(NSData * _Nonnull) formData name:(NSString * _Nonnull) name fileName:(NSString * _Nonnull) fileName mimeType:(NSString * _Nonnull) mimeType;
|
||||
/**
|
||||
* <#Description#>
|
||||
*
|
||||
* @param image <#image description#>
|
||||
* @param name <#name description#>
|
||||
* @param fileName <#fileName description#>
|
||||
* @param mimeType <#mimeType description#>
|
||||
*
|
||||
* @return <#return value description#>
|
||||
*/
|
||||
+ (instancetype _Nonnull) formDataFromUIImage:(UIImage * _Nonnull) image name:(NSString * _Nonnull) name fileName:(NSString * _Nonnull) fileName mimeType:(NSString * _Nonnull) mimeType;
|
||||
/**
|
||||
* <#Description#>
|
||||
*
|
||||
* @param image <#image description#>
|
||||
* @param compression <#compression description#>
|
||||
* @param name <#name description#>
|
||||
* @param fileName <#fileName description#>
|
||||
* @param mimeType <#mimeType description#>
|
||||
*
|
||||
* @return <#return value description#>
|
||||
*/
|
||||
+ (instancetype _Nonnull) formDataFromUIImage:(UIImage * _Nonnull) image compression:(CGFloat) compression name:(NSString * _Nonnull) name fileName:(NSString * _Nonnull) fileName mimeType:(NSString * _Nonnull) mimeType;
|
||||
|
||||
|
||||
@end
|
||||
40
Pod/Classes/PNObjectFormData.m
Normal file
40
Pod/Classes/PNObjectFormData.m
Normal file
@ -0,0 +1,40 @@
|
||||
//
|
||||
// PNObjectFormData.m
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 16/02/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import "PNObjectFormData.h"
|
||||
|
||||
@implementation PNObjectFormData
|
||||
|
||||
+ (instancetype _Nonnull) formDataFromNSData:(NSData * _Nonnull) formData name:(NSString * _Nonnull) name fileName:(NSString * _Nonnull) fileName mimeType:(NSString * _Nonnull) mimeType {
|
||||
PNObjectFormData * responseData = [PNObjectFormData new];
|
||||
|
||||
[responseData setFormData:formData];
|
||||
[responseData setName:name];
|
||||
[responseData setFileName:fileName];
|
||||
[responseData setMimeType:mimeType];
|
||||
|
||||
return responseData;
|
||||
}
|
||||
|
||||
+ (instancetype _Nonnull) formDataFromUIImage:(UIImage * _Nonnull) image name:(NSString * _Nonnull) name fileName:(NSString * _Nonnull) fileName mimeType:(NSString * _Nonnull) mimeType {
|
||||
return [self formDataFromUIImage:image compression:1 name:name fileName:fileName mimeType:mimeType];
|
||||
}
|
||||
|
||||
+ (instancetype _Nonnull) formDataFromUIImage:(UIImage * _Nonnull) image compression:(CGFloat) compression name:(NSString * _Nonnull) name fileName:(NSString * _Nonnull) fileName mimeType:(NSString * _Nonnull) mimeType {
|
||||
PNObjectFormData * responseData = [PNObjectFormData new];
|
||||
|
||||
[responseData setFormData:UIImageJPEGRepresentation(image, compression)];
|
||||
[responseData setName:name];
|
||||
[responseData setFileName:fileName];
|
||||
[responseData setMimeType:mimeType];
|
||||
|
||||
return responseData;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
Loading…
x
Reference in New Issue
Block a user