Refactoring duplicate code between storage.key and storage.bucket.