Class: SpreeCmCommissioner::S3PresignedUrl

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serialization
Defined in:
app/models/spree_cm_commissioner/s3_presigned_url.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket_name, object_key, uuid = nil) ⇒ S3PresignedUrl

Returns a new instance of S3PresignedUrl.



14
15
16
17
18
19
20
21
22
# File 'app/models/spree_cm_commissioner/s3_presigned_url.rb', line 14

def initialize(bucket_name, object_key, uuid = nil)
  @id = uuid.presence || generate_secure_random

  if object_key.blank?
    @error_message = I18n.t('s3_signed_url.missing_file_name')
  else
    @s3_direct_post = presigned_post(bucket_name, object_key)
  end
end

Instance Attribute Details

#error_messageObject

Returns the value of attribute error_message.



5
6
7
# File 'app/models/spree_cm_commissioner/s3_presigned_url.rb', line 5

def error_message
  @error_message
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'app/models/spree_cm_commissioner/s3_presigned_url.rb', line 5

def id
  @id
end

#s3_direct_postObject (readonly)

Returns the value of attribute s3_direct_post.



4
5
6
# File 'app/models/spree_cm_commissioner/s3_presigned_url.rb', line 4

def s3_direct_post
  @s3_direct_post
end

Instance Method Details

#hostObject



10
11
12
# File 'app/models/spree_cm_commissioner/s3_presigned_url.rb', line 10

def host
  URI.parse(url).host
end