Sha256: fd294dceb869e244550420471eda336afa95b47d69e13ddf35763460d7c17d7c
Contents?: true
Size: 727 Bytes
Versions: 1
Compression:
Stored size: 727 Bytes
Contents
# frozen_string_literal: true require 'aws-sdk-s3' module SolidusFeeds module Publishers class S3 attr_reader :object_key, :bucket, :resource NoContentError = Class.new(StandardError) def initialize(object_key:, bucket:, client: Aws::S3::Client.new) @object_key = object_key @bucket = bucket @resource = Aws::S3::Resource.new(client: client) end def call Tempfile.create(object_key) do |io| yield io io.rewind raise NoContentError, "no content was generated" if io.eof? object = resource.bucket(bucket).object(object_key) object.put(body: io, acl: 'public-read') end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_feeds-0.1.0 | lib/solidus_feeds/publishers/s3.rb |