-
Notifications
You must be signed in to change notification settings - Fork 6
/
MVUploadAuthorization.m
111 lines (100 loc) · 3.08 KB
/
MVUploadAuthorization.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#import "MVUploadAuthorization.h"
@interface MVUploadAuthorization ()
@property (strong, readwrite) NSString *service;
// S3
@property (strong, readwrite) NSString *bucket;
@property (strong, readwrite) NSString *uploadURL;
@property (strong, readwrite) NSString *accessKeyId;
@property (strong, readwrite) NSString *startsWith;
@property (strong, readwrite) NSString *acl;
@property (strong, readwrite) NSString *successActionRedirect;
@property (readwrite) long long maximumSizeInBytes;
@property (strong, readwrite) NSString *policy;
@property (strong, readwrite) NSString *signature;
@property (strong, readwrite) NSDate *expirationDate;
// CloudApp
@property (strong, readwrite) NSString *email;
@property (strong, readwrite) NSString *password;
@end
@implementation MVUploadAuthorization
@synthesize service = service_,
bucket = bucket_,
uploadURL = uploadURL_,
accessKeyId = accessKeyId_,
startsWith = startsWith_,
acl = acl_,
successActionRedirect = successActionRedirect_,
maximumSizeInBytes = maximumSizeInBytes_,
policy = policy_,
signature = signature_,
expirationDate = expirationDate_,
email = email_,
password = password_;
- (id)init
{
self = [super init];
if(self)
{
service_ = nil;
bucket_ = nil;
uploadURL_ = nil;
accessKeyId_ = nil;
startsWith_ = nil;
acl_ = nil;
successActionRedirect_ = nil;
maximumSizeInBytes_ = 0;
policy_ = nil;
signature_ = nil;
expirationDate_ = nil;
email_ = nil;
password_ = nil;
}
return self;
}
- (id)initWithService:(NSString*)service
bucket:(NSString*)bucket
uploadURL:(NSString*)uploadURL
accessKeyId:(NSString*)accessKeyId
startsWith:(NSString*)startsWith
acl:(NSString*)acl
successActionRedirect:(NSString*)successActionRedirect
maximumSizeInBytes:(long long)maximumSizeInBytes
policy:(NSString*)policy
signature:(NSString*)signature
expirationDate:(NSDate*)expirationDate
{
self = [super init];
if(self)
{
NSAssert([service isEqualToString:kMVUploadAuthorizationServiceS3],
@"kMVUploadAuthorizationServiceS3 service is only supported");
service_ = service;
bucket_ = bucket;
uploadURL_ = uploadURL;
accessKeyId_ = accessKeyId;
startsWith_ = startsWith;
acl_ = acl;
successActionRedirect_ = successActionRedirect;
maximumSizeInBytes_ = maximumSizeInBytes;
policy_ = policy;
signature_ = signature;
expirationDate_ = expirationDate;
}
return self;
}
- (id)initWithCloudAppEmail:(NSString *)email password:(NSString *)password
{
self = [super init];
if(self)
{
service_ = kMVUploadAuthorizationServiceCloudApp;
email_ = email;
password_ = password;
}
return self;
}
- (BOOL)isExpired
{
return [self.expirationDate compare:[NSDate date]] != NSOrderedDescending;
}
@end