The client.head_object() call needs to be inside the try block so we trap any errors and handle them appropriately.
If the key exists it will just drop through and return True.
If the key does not exist it will drop into the except block where we should check for "404" response to confirm the error is just that the key does not exist, otherwise the error is something else and should be raised.
The client.head_object() call needs to be inside the try block so we trap any errors and handle them appropriately.
If the key exists it will just drop through and return True.
If the key does not exist it will drop into the except block where we should check for "404" response to confirm the error is just that the key does not exist, otherwise the error is something else and should be raised.