Class: RemoteTranslationLoader::Fetchers::S3Fetcher
- Inherits:
-
BaseFetcher
- Object
- BaseFetcher
- RemoteTranslationLoader::Fetchers::S3Fetcher
- Defined in:
- lib/remote_translation_loader/fetchers/s3_fetcher.rb
Instance Method Summary collapse
- #fetch(key) ⇒ Object
-
#initialize(bucket, s3_client: nil) ⇒ S3Fetcher
constructor
A new instance of S3Fetcher.
Methods inherited from BaseFetcher
Constructor Details
#initialize(bucket, s3_client: nil) ⇒ S3Fetcher
Returns a new instance of S3Fetcher.
6 7 8 9 |
# File 'lib/remote_translation_loader/fetchers/s3_fetcher.rb', line 6 def initialize(bucket, s3_client: nil) @bucket = bucket @s3_client_override = s3_client end |
Instance Method Details
#fetch(key) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/remote_translation_loader/fetchers/s3_fetcher.rb', line 11 def fetch(key) response = s3_client.get_object(bucket: @bucket, key: key) parse(response.body.read, format: format_for(key)) rescue Aws::S3::Errors::ServiceError => e raise FetchError, "Failed to fetch #{key} from S3 bucket #{@bucket}: #{e.}" end |