I'm using the following code to check if a file exists on S3. Unfortunately, I'm never getting an error. It seems to be that the AWS SDK should return an error but that it doesn't because the body is empty and cannot be deserialized in a S3 error.
How can I work around this issue? A solution would be to check myself for the 404 in the response but I don't find a way to do that with the task
.
s3.headObject(headRequest).continue({ task in
task.
if let taskError = task.error {
if let error = task.error as NSError? {
if error.domain == AWSS3ErrorDomain && AWSS3ErrorType(rawValue: error.code) == AWSS3ErrorType.noSuchKey {
return successBlock(false)
}
}
errorBlock(taskError)
return nil
}
return successBlock(true)
});
(The same issue arises if the error is a 403)