Sha256: b73f5b930d1d45e75a6fc99b7831f33ef0e590c45497b0923c96711fbf618738

Contents?: true

Size: 689 Bytes

Versions: 9

Compression:

Stored size: 689 Bytes

Contents

module CsvHelper
  class Aws < Base
    S3_BUCKET = APP_CONFIG['s3_bucket']
    S3_FOLDER = APP_CONFIG['s3_folder'] || 'results'

    def url
      Pester.s3.retry do
        obj = AwsS3.resource.bucket(S3_BUCKET).object(key)
        if obj.exists?
          obj.presigned_url(:get, response_content_disposition: "attachment; filename=result_#{@result_id}.csv", expires_in: 3600)
        else
          nil
        end
      end
    end

    def store!
      Pester.s3.retry do
        obj = AwsS3.resource.bucket(S3_BUCKET).object(key)
        obj.upload_file(filepath)
      end
    end

    private

    def key
      S3_FOLDER ? "#{S3_FOLDER}/#{filename}" : filename
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
aleph_analytics-0.2.0 lib/csv_helper/aws.rb
aleph_analytics-0.1.0 lib/csv_helper/aws.rb
aleph_analytics-0.0.6 lib/csv_helper/aws.rb
aleph_analytics-0.0.5 lib/csv_helper/aws.rb
aleph_analytics-0.0.4 lib/csv_helper/aws.rb
aleph_analytics-0.0.3 lib/csv_helper/aws.rb
aleph_analytics-0.0.2 lib/csv_helper/aws.rb
aleph_analytics-0.0.1.alpha lib/csv_helper/aws.rb
aleph_analytics-0.0.0.alpha lib/csv_helper/aws.rb