(Objective-C) Generate S3 Signed URL
Demonstrates how to generate a pre-signed S3 URL.
#import <CkoHttp.h>
#import <NSString.h>
#import <CkoDateTime.h>
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
// Insert your access key here:
http.AwsAccessKey = @"ABQXXABC83ABCDEFVQXX";
// Insert your secret key here:
http.AwsSecretKey = @"XXXXYYYYabcdABCD12345678xxxxyyyyzzzz";
NSString *bucketName = @"testbucket";
NSString *path = @"starfish.jpg";
CkoDateTime *expireTime = [[CkoDateTime alloc] init];
[expireTime SetFromCurrentSystemTime];
BOOL bLocalTime = NO;
// Set the expiration time to 1 hour from the current time.
[expireTime SetFromUnixTime: bLocalTime t: [expireTime GetAsUnixTime: bLocalTime] + 3600];
NSString *signedUrl = 0;
signedUrl = [http S3_GenerateUrl: bucketName path: path expire: expireTime];
if (http.LastMethodSuccess != YES) {
NSLog(@"%@",http.LastErrorText);
}
else {
NSLog(@"%@",signedUrl);
}
|