Refactor photo upload code a bit to get around aws error.