Sha256: 7eb96ec929af92aedd52474f5111d18b9926d4652d4453fa430028bcf29556c2
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require "cloud_job_base" require "cloud_storage_handler" require "aws-sdk" module CloudJobAws class AwsInternalStorageHandler < CloudJobBase::InternalStorageHandler def init_connection raise "Key not set." if ENV['AWS_ACCESS_KEY_ID'].nil? @key = ENV['AWS_ACCESS_KEY_ID'] raise "Secret not set." if ENV['AWS_SECRET_ACCESS_KEY'].nil? @secret = ENV['AWS_SECRET_ACCESS_KEY'] @s3_default = Aws::S3::Resource.new(region: "eu-west-1", credentials: Aws::Credentials.new(@key, @secret)) @default_bucket = @s3_default.bucket("user-exe-files") end def put_file(file_path) name = File.basename(file_path) object = @default_bucket.object(name) object.upload_file(file_path) return object.key end def read_file(file_url) @default_bucket.get(file_url) end def presigned_post(bucket_key) @default_bucket.presigned_post(key: bucket_key, success_action_status: '201', acl: 'public-read') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cloud_job_aws-0.1.0 | lib/cloud_storage_aws.rb |