-
Notifications
You must be signed in to change notification settings - Fork 1
/
AFAmazonS3Client.h
145 lines (119 loc) · 5.5 KB
/
AFAmazonS3Client.h
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//
// AFAmazonS3Client.h
//
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "AFHTTPClient.h"
extern NSString * const kAFAmazonS3BaseURLString;
@interface AFAmazonS3Client : AFHTTPClient
/**
*/
@property (nonatomic, retain) NSURL *baseURL;
/**
*/
@property (nonatomic, copy) NSString *bucket;
/**
*/
- (id)initWithAccessKeyID:(NSString *)accessKey
secret:(NSString *)secret;
/**
*/
- (void)enqueueS3RequestOperationWithMethod:(NSString *)method
path:(NSString *)path
parameters:(NSDictionary *)parameters
success:(void (^)(id responseObject))success
failure:(void (^)(NSError *error))failure;
///-------------------------
/// @name Service Operations
///-------------------------
/**
Returns a list of all buckets owned by the authenticated request sender.
*/
- (void)getServiceWithSuccess:(void (^)(id responseObject))success
failure:(void (^)(NSError *error))failure;
///------------------------
/// @name Bucket Operations
///------------------------
/**
Lists information about the objects in a bucket for a user that has read access to the bucket.
*/
- (void)getBucket:(NSString *)bucket
success:(void (^)(id responseObject))success
failure:(void (^)(NSError *error))failure;
/**
Creates a new bucket belonging to the account of the authenticated request sender. Optionally, you can specify a EU (Ireland) or US-West (N. California) location constraint.
*/
- (void)putBucket:(NSString *)bucket
parameters:(NSDictionary *)parameters
success:(void (^)(id responseObject))success
failure:(void (^)(NSError *error))failure;
/**
Deletes the specified bucket. All objects in the bucket must be deleted before the bucket itself can be deleted.
*/
- (void)deleteBucket:(NSString *)bucket
success:(void (^)(id responseObject))success
failure:(void (^)(NSError *error))failure;
///----------------------------------------------
/// @name Object Operations
///----------------------------------------------
/**
Retrieves information about an object for a user with read access without fetching the object.
*/
- (void)headObjectWithPath:(NSString *)path
success:(void (^)(id responseObject))success
failure:(void (^)(NSError *error))failure;
/**
Gets an object for a user that has read access to the object.
*/
- (void)getObjectWithPath:(NSString *)path
progress:(void (^)(NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))progress
success:(void (^)(id responseObject, NSData *responseData))success
failure:(void (^)(NSError *error))failure;
/**
Gets an object for a user that has read access to the object.
*/
- (void)getObjectWithPath:(NSString *)path
outputStream:(NSOutputStream *)outputStream
progress:(void (^)(NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))progress
success:(void (^)(id responseObject))success
failure:(void (^)(NSError *error))failure;
/**
Adds an object to a bucket using forms.
*/
- (void)postObjectWithFile:(NSString *)path
parameters:(NSDictionary *)parameters
progress:(void (^)(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
success:(void (^)(id responseObject))success
failure:(void (^)(NSError *error))failure;
/**
Adds an object to a bucket for a user that has write access to the bucket. A success response indicates the object was successfully stored; if the object already exists, it will be overwritten.
*/
- (void)putObjectWithFile:(NSString *)path
parameters:(NSDictionary *)parameters
progress:(void (^)(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
success:(void (^)(id responseObject))success
failure:(void (^)(NSError *error))failure;
/**
Deletes the specified object. Once deleted, there is no method to restore or undelete an object.
*/
- (void)deleteObjectWithPath:(NSString *)path
success:(void (^)(id responseObject))success
failure:(void (^)(NSError *error))failure;
@end