-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove GET/ACL constructors Added lots of comments General cleanup
- Loading branch information
Showing
4 changed files
with
91 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,81 @@ | ||
// | ||
// ASIS3Request.h | ||
// Mac | ||
// | ||
// Created by Ben Copsey on 30/06/2009. | ||
// Copyright 2009 All-Seeing Interactive. All rights reserved. | ||
// | ||
// A (basic) class for accessing data stored on Amazon's Simple Storage Service (http://aws.amazon.com/s3/) | ||
// It uses the REST API, with canned access policies rather than full support for ACLs (though if you build/parse them yourself you can still use ACLs) | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "ASIHTTPRequest.h" | ||
|
||
// See http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?RESTAccessPolicy.html for what these mean | ||
extern NSString *const ASIS3AccessPolicyPrivate; // This is the default in S3 when no access policy header is provided | ||
extern NSString *const ASIS3AccessPolicyPublicRead; | ||
extern NSString *const ASIS3AccessPolicyPublicReadWrote; | ||
extern NSString *const ASIS3AccessPolicyAuthenticatedRead; | ||
|
||
@interface ASIS3Request : ASIHTTPRequest { | ||
|
||
// Your S3 access key. Set it on the request, or set it globally using [ASIS3Request setSharedAccessKey:] | ||
NSString *accessKey; | ||
|
||
// Your S3 secret access key. Set it on the request, or set it globally using [ASIS3Request setSharedSecretAccessKey:] | ||
NSString *secretAccessKey; | ||
|
||
// Name of the bucket to talk to | ||
NSString *bucket; | ||
|
||
// path to the resource you want to access on S3. Leave empty for the bucket root | ||
NSString *path; | ||
|
||
// The string that will be used in the HTTP date header. Generally you'll want to ignore this and let the class add the current date for you, but the accessor is used by the tests | ||
NSString *dateString; | ||
|
||
// The mime type of the content for PUT requests | ||
// Set this if having the correct mime type returned to you when you GET the data is important (eg it will be served by a web-server) | ||
// Will be set to 'application/octet-stream' otherwise in iPhone apps, or autodetected on Mac OS X | ||
NSString *mimeType; | ||
NSString *accessKey; | ||
NSString *secretAccessKey; | ||
|
||
NSString *accessPolicy; | ||
} | ||
|
||
#pragma mark Constructors | ||
|
||
// Create a request, building an appropriate url | ||
+ (id)requestWithBucket:(NSString *)bucket path:(NSString *)path; | ||
|
||
// Create a PUT request using the file at filePath as the body | ||
+ (id)PUTRequestForFile:(NSString *)filePath withBucket:(NSString *)bucket path:(NSString *)path; | ||
+ (id)GETRequestWithBucket:(NSString *)bucket path:(NSString *)path; | ||
+ (id)listRequestWithBucket:(NSString *)bucket prefix:(NSString *)prefix maxResults:(int)maxResults marker:(NSString *)marker; | ||
+ (id)ACLRequestWithBucket:(NSString *)bucket path:(NSString *)path; | ||
|
||
// Create a list request | ||
+ (id)listRequestWithBucket:(NSString *)bucket prefix:(NSString *)prefix maxResults:(int)maxResults marker:(NSString *)marker; | ||
|
||
// Generates the request headers S3 needs | ||
// Automatically called before the request begins in startRequest | ||
- (void)generateS3Headers; | ||
- (void)setDate:(NSDate *)date; | ||
|
||
// Uses the supplied date to create a Date header string | ||
- (void)setDate:(NSDate *)date; | ||
|
||
// Only works on Mac OS, will always return 'application/octet-stream' on iPhone | ||
+ (NSString *)mimeTypeForFileAtPath:(NSString *)path; | ||
|
||
#pragma mark Shared access keys | ||
|
||
// Get and set the global access key, this will be used for all requests the access key hasn't been set for | ||
+ (NSString *)sharedAccessKey; | ||
+ (void)setSharedAccessKey:(NSString *)newAccessKey; | ||
+ (NSString *)sharedSecretAccessKey; | ||
+ (void)setSharedSecretAccessKey:(NSString *)newAccessKey; | ||
|
||
#pragma mark S3 Authentication helpers | ||
+ (NSData *)HMACSHA1withKey:(NSString *)key forString:(NSString *)string; | ||
+ (NSString *)base64forData:(NSData *)theData; | ||
|
||
@property (retain) NSString *bucket; | ||
@property (retain) NSString *path; | ||
@property (retain) NSString *dateString; | ||
@property (retain) NSString *mimeType; | ||
@property (retain) NSString *accessKey; | ||
@property (retain) NSString *secretAccessKey; | ||
@property (assign) NSString *accessPolicy; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters