Skip to content

Loading…

Add support for Amazon S3's server-side encryption #323

Open
wants to merge 1 commit into from

1 participant

@camdez

Adds a property to ASIS3ObjectRequest to instruct Amazon S3 to store the objected encrypted, as described here.

ASIS3ObjectRequest *request = 
 [ASIS3ObjectRequest PUTRequestForFile:filePath withBucket:@"my-bucket" key:@"path/to/the/object"];
[request setUseServerSideEncryption:YES]; // <-- use SSE
[request startSynchronous];
if ([request error]) {
   NSLog(@"%@",[[request error] localizedDescription]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +1 −0 Classes/S3/ASIS3ObjectRequest.h
  2. +4 −0 Classes/S3/ASIS3ObjectRequest.m
View
1 Classes/S3/ASIS3ObjectRequest.h
@@ -77,4 +77,5 @@ extern NSString *const ASIS3StorageClassReducedRedundancy;
@property (retain, nonatomic) NSString *mimeType;
@property (retain, nonatomic) NSString *subResource;
@property (retain, nonatomic) NSString *storageClass;
+@property (assign, nonatomic) BOOL useServerSideEncryption;
@end
View
4 Classes/S3/ASIS3ObjectRequest.m
@@ -142,6 +142,9 @@ - (NSMutableDictionary *)S3Headers
if ([self storageClass]) {
[headers setObject:[self storageClass] forKey:@"x-amz-storage-class"];
}
+ if ([self useServerSideEncryption]) {
+ [headers setObject:@"AES256" forKey:@"x-amz-server-side-encryption"];
+ }
return headers;
}
@@ -161,4 +164,5 @@ - (NSString *)stringToSignForHeaders:(NSString *)canonicalizedAmzHeaders resourc
@synthesize mimeType;
@synthesize subResource;
@synthesize storageClass;
+@synthesize useServerSideEncryption;
@end
Something went wrong with that request. Please try again.