KidIcarus271
KidIcarus271

Reputation: 154

S3GetObjectMetadataResponse Error, Crashes. How can I check it?

I have an app that builds a dynamic list of files to be downloaded, using the Amazon S3 iOS SDK. No matter where in the queue I start the downloading from, the same file consistently crashes the application.

I've pinpointed the problem using breaks, and it's coming from my S3GetObjectMetadataResponse line as I attempt to get the size of the file before downloading, for the sake of configuring the progress bar.

self.S3 = [[AmazonS3Client alloc] initWithAccessKey:@"xxxxxxxxxxxxxxxxxxxx" withSecretKey:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"];    
S3GetObjectMetadataRequest *getMetadataRequest = [[S3GetObjectMetadataRequest alloc] initWithKey:self.file.fileName withBucket:[self.file contentURLBucket]];
S3GetObjectMetadataResponse *metadataResponse = [self.S3 getObjectMetadata:getMetadataRequest];

If I comment out the last line, everything works as intended - except for the progress bar, of course.

What can I do to handle S3GetObjectMetadataResponse errors? Is there a better way I can check the file size before downloading?

Thanks!

Upvotes: 2

Views: 159

Answers (1)

Bob Kinney
Bob Kinney

Reputation: 9020

As mentioned in my comment, you'll want to ensure that either exceptions are disabled in the AWS SDK for iOS or that you use a @try/@catch block in your code around synchronous calls when using the SDK.

This post on our blog explains how to disable exceptions and how to work with the SDK when exceptions are disabled.

This post is the first in a series that explains the various methods for using the SDK asynchronously. It is worth noting that if you make asynchronous requests with exceptions enabled you don't need the @try/@catch blocks.

Upvotes: 1

Related Questions