Class: Vert::Concerns::DocumentStoreable::DocumentAttachment
- Inherits:
-
Object
- Object
- Vert::Concerns::DocumentStoreable::DocumentAttachment
- Defined in:
- lib/vert/concerns/document_storeable.rb
Instance Attribute Summary collapse
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#storage_object_id ⇒ Object
readonly
Returns the value of attribute storage_object_id.
Instance Method Summary collapse
- #attached? ⇒ Boolean
- #byte_size ⇒ Object
- #content_type ⇒ Object
- #details ⇒ Object
- #download ⇒ Object
- #filename ⇒ Object
-
#initialize(object_id:, resource:, owner:) ⇒ DocumentAttachment
constructor
A new instance of DocumentAttachment.
- #url(disposition: "inline", expires_in: 3600) ⇒ Object
Constructor Details
#initialize(object_id:, resource:, owner:) ⇒ DocumentAttachment
Returns a new instance of DocumentAttachment.
137 138 139 140 141 |
# File 'lib/vert/concerns/document_storeable.rb', line 137 def initialize(object_id:, resource:, owner:) @storage_object_id = object_id @resource = resource @owner = owner end |
Instance Attribute Details
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
135 136 137 |
# File 'lib/vert/concerns/document_storeable.rb', line 135 def owner @owner end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
135 136 137 |
# File 'lib/vert/concerns/document_storeable.rb', line 135 def resource @resource end |
#storage_object_id ⇒ Object (readonly)
Returns the value of attribute storage_object_id.
135 136 137 |
# File 'lib/vert/concerns/document_storeable.rb', line 135 def storage_object_id @storage_object_id end |
Instance Method Details
#attached? ⇒ Boolean
169 170 171 |
# File 'lib/vert/concerns/document_storeable.rb', line 169 def attached? storage_object_id.present? end |
#byte_size ⇒ Object
165 166 167 |
# File 'lib/vert/concerns/document_storeable.rb', line 165 def byte_size details&.dig(:size) end |
#content_type ⇒ Object
161 162 163 |
# File 'lib/vert/concerns/document_storeable.rb', line 161 def content_type details&.dig(:mime_type) end |
#details ⇒ Object
152 153 154 155 |
# File 'lib/vert/concerns/document_storeable.rb', line 152 def details result = client.object(storage_object_id) result[:success] ? result[:data] : nil end |
#download ⇒ Object
148 149 150 |
# File 'lib/vert/concerns/document_storeable.rb', line 148 def download client.download(object_id: storage_object_id) end |
#filename ⇒ Object
157 158 159 |
# File 'lib/vert/concerns/document_storeable.rb', line 157 def filename details&.dig(:original_filename) end |
#url(disposition: "inline", expires_in: 3600) ⇒ Object
143 144 145 146 |
# File 'lib/vert/concerns/document_storeable.rb', line 143 def url(disposition: "inline", expires_in: 3600) result = client.download_url(object_id: storage_object_id, disposition: disposition, expires_in: expires_in) result[:success] ? result[:data][:url] : nil end |