0

i tried searching but can't find better, i also tried above code but it beyond of my understanding and give me many errors please help me out....

S3GetPreSignedURLRequest * request = [[S3GetPreSignedURLRequest alloc] init];
request.bucket = @"bucket";
request.key = @"key";
request.contentType = @"image/jpeg";
request.httpVerb = @"GET";

AmazonCredentials *credentials = [[AmazonCredentials alloc] initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY];
request.credentials = credentials;

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];
4

1 回答 1

0

在应用程序中包含秘密并在现场创建预签名 URL 是没有意义的。iOS 应用程序不应包含 S3 机密,因为这些机密可用于执行您几乎肯定不希望您的用户执行的操作(例如,上传和删除文件、创建和删除存储桶等)。

如果您希望 PDF 可公开访问,请在上传时将其设置为公开,并且可以使用任何 HTTP 库(例如http://s3.amazonaws.com/yourbucket/yourfile.pdf)在其 URL 上使用它. 您不需要 S3 框架来执行此操作 -NSURLConnection甚至只是一个 Web 视图都可以正常工作。

于 2013-09-30T05:31:23.640 回答