Sha256: 8d1415b7ae0fdc6e6035d5a0b2289feaf75570053b612433d5a7726a40fd87fb

Contents?: true

Size: 529 Bytes

Versions: 4

Compression:

Stored size: 529 Bytes

Contents

# frozen_string_literal: true

require 'aws-sdk-rails'

module Lcms
  module Engine
    class S3Service
      def self.create_object(key)
        ::Aws::S3::Resource
          .new(region: ENV.fetch('AWS_REGION'))
          .bucket(ENV.fetch('AWS_S3_BUCKET_NAME'))
          .object(key)
      end

      def self.upload(key, data)
        object = create_object key
        object.put(body: data)
        object.public_url
      end

      def self.url_for(key)
        create_object(key).public_url
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lcms-engine-0.1.4 app/services/lcms/engine/s3_service.rb
lcms-engine-0.1.3 app/services/lcms/engine/s3_service.rb
lcms-engine-0.1.2 app/services/lcms/engine/s3_service.rb
lcms-engine-0.1.0 app/services/lcms/engine/s3_service.rb