I am trying to download image from Amazon using pre-signed URL. Here is the code, but something must be missing and the image did not show. Thanks in advance!
//Set up the request
S3GetPreSignedURLRequest * request = [[S3GetPreSignedURLRequest alloc] init];
request.bucket = @"a";
request.key = @"b";
request.contentType = @"image/jpeg";
request.httpVerb = @"GET";
//set credential
AmazonCredentials * credentials = [[AmazonCredentials alloc] initWithAccessKey:ACCESS_KEY withSecretKey:SECRET_KEY];
request.credentials = credentials;
//set expire
NSDateComponents *components = [[[NSDateComponents alloc] init] autorelease];
[components setHour:1];
NSDate * oneHourFromNow = [[NSCalendar currentCalendar] dateByAddingComponents:components toDate:[NSDate date] options:0];
request.expires = oneHourFromNow;
//get the presigned URL
NSURL * url = [[Constants s3] getPreSignedURL: request];
The
expiretakes UTC time, not a local time.