AFAmazonS3Manager
是一个用于与 Amazon S3 API 交互的 AFHTTPRequestOperationManager
子类。
AFAmazonS3Manager *s3Manager = [[AFAmazonS3Manager alloc] initWithAccessKeyID:@"..." secret:@"..."];
s3Manager.requestSerializer.region = AFAmazonS3USWest1Region;
s3Manager.requestSerializer.bucket = @"my-bucket-name";
NSString *destinationPath = @"/pathOnS3/to/file.txt";
[s3Manager postObjectWithFile:@"/path/to/file.txt"
destinationPath:destinationPath
parameters:nil
progress:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
NSLog(@"%f%% Uploaded", (totalBytesWritten / (totalBytesExpectedToWrite * 1.0f) * 100));
}
success:^(AFAmazonS3ResponseObject *responseObject) {
NSLog(@"Upload Complete: %@", responseObject.URL);
}
failure:^(NSError *error) {
NSLog(@"Error: %@", error);
}];
Mattt Thompson
AFAmazonS3Manager 在 MIT 许可协议下提供。有关更多信息,请参阅 LICENSE 文件。