AWSS3Client - is an Alternative AFNetworking Client, AFHTTPClient subclass for interacting with the Amazon S3 API.
As the S3 API returns XML responses, you may find it useful to include AFKissXMLRequestOperation (just remember to do -registerHTTPOperationClass:
)
**Caution:** This code is still in its early stages of development, so exercise caution when incorporating this into production code.
AWSS3Client *s3Client = [[AWSS3Client alloc] initWithAccessKeyID:@"..." secret:@"..."];
s3Client.bucket = @"the-bucket";
[s3Client putObjectWithData:imageData key:key mimeType:@"image/jpg" progress:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
NSLog(@"%f%% Uploaded", (totalBytesWritten / (totalBytesExpectedToWrite * 1.0f) * 100));
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Upload Successful!");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Upload Failed...");
}];
- This code uses Automatic Reference Counting, if your project does not use ARC, you must add the
-fobjc-arc
compiler flag to each implementation files inTarget Settings > Build Phases > Compile Source
. - This code also uses the literals syntax, so at least Xcode 4.5 is required.
If you're using CocoaPods
, there's nothing simpler.
Add the following to your Podfile
and run pod install
pod 'AWSS3Client', :git => 'https://github.com/swivl/AWSS3Client.git'
Don't forget to #import "AWSS3Client.h"
where it's needed.
Sergei Me
AWSS3Client is available under the MIT license. See the LICENSE
file for more info.