2

I'm trying to create a signed url for AWS S3, i just want the URL for a file in my bucket, i don't want to use it for upload/download.

I've tried AFNetworking, following the steps on Amazons documentation and am now using the AWS iOS SDK.

So far i have this:

AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider        credentialsWithAccessKey:@"Access Key" secretKey:@"secret key"];
AWSServiceConfiguration *configuration = [AWSServiceConfiguration    configurationWithRegion:AWSRegionUSWest2  credentialsProvider:credentialsProvider];

[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
AWSS3PreSignedURLBuilder * urlBuilder  = [[AWSS3PreSignedURLBuilder alloc]       initWithConfiguration:configuration];

AWSS3GetPreSignedURLRequest *preSignedURLRequest = [AWSS3GetPreSignedURLRequest new];
preSignedURLRequest.bucket = @"bucket-name";
preSignedURLRequest.key = @"/filename";
preSignedURLRequest.HTTPMethod = AWSHTTPMethodGET;
preSignedURLRequest.expires = [NSDate dateWithTimeIntervalSinceNow:3600];

 NSURL *preSignedURL = [urlBuilder getPreSignedURL:preSignedURLRequest];

NSLog(@"%@", preSignedURL);

I'm getting a lot of errors about the code being depreciated, but more importantly i Know that the method getPreSignedURL returns a type (AWSTask *), my question is how to turn a AWSTask into the signed url?

Also i don't plan on leaving the keys in my code this is just temporary for testing.

If anyone could help me find how to get the preSignedURL that'd be a great help. Thanks

Ben
  • 342
  • 5
  • 13

3 Answers3

0

You can check out Taming the AWS framework to upload a large file to S3 it also covers generating a pre-signed URL in swift

otusweb
  • 1,638
  • 1
  • 19
  • 30
  • This answer is not relevant to the asked question. Answer should be only for "Generating a signed URL for AWS S3" not for uploading or downloading – A K Sep 04 '19 at 06:42
  • Thanks for your comment @Amit Anmol, if you check the article you'll see that Generating a pre-signed URL is covered in the article under the "CREATE THE PARTS' UPLOAD REQUESTS" section. – otusweb Sep 04 '19 at 08:38
-1

Have you tried S3BackgroundTransfer-Sample? It should help you get started.

Yosuke
  • 3,759
  • 1
  • 11
  • 21
  • This answer is not relevant to the asked question. Answer should be only for "Generating a signed URL for AWS S3" not for transferring, uploading or downloading. – A K Sep 04 '19 at 06:46
-2

I am assuming you are trying to handle background upload/downloads. For this purpose you can use AWSS3TransferUtility.

You can read more details on http://docs.aws.amazon.com/mobile/sdkforios/developerguide/s3transferutility.html

  • Welcome to Stack Overflow! Link-only answers are not helpful, especially if the link should break. Please provide the important aspects to your answer here, and provide links for reference. – Joe C Dec 01 '16 at 22:35
  • This answer is not relevant to the asked question. Answer should be only for "Generating a signed URL for AWS S3" not for uploading or downloading. – A K Sep 04 '19 at 06:43