Class: Itrp::Attachments
- Inherits:
-
Object
- Object
- Itrp::Attachments
- Defined in:
- lib/itrp/client/attachments.rb
Constant Summary collapse
- AWS_PROVIDER =
'aws'
- FILENAME_TEMPLATE =
'${filename}'
Instance Method Summary collapse
-
#initialize(client) ⇒ Attachments
constructor
A new instance of Attachments.
-
#upload_attachments!(path, data) ⇒ Object
upload the attachments in :attachments to ITRP and return the data with the uploaded attachment info.
Constructor Details
#initialize(client) ⇒ Attachments
Returns a new instance of Attachments.
7 8 9 |
# File 'lib/itrp/client/attachments.rb', line 7 def initialize(client) @client = client end |
Instance Method Details
#upload_attachments!(path, data) ⇒ Object
upload the attachments in :attachments to ITRP and return the data with the uploaded attachment info
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/itrp/client/attachments.rb', line 12 def (path, data) raise_exceptions = !!data.delete(:attachments_exception) = [data.delete(:attachments)].flatten.compact return if .empty? # retrieve the upload configuration for this record from ITRP storage = @client.get(path =~ /\d+$/ ? path : "#{path}/new", {attachment_upload_token: true}, @client.send(:expand_header))[:storage_upload] report_error("Attachments not allowed for #{path}", raise_exceptions) and return unless storage # upload each attachment and store the {key, filesize} has in the note_attachments parameter data[(path)] = .map {|| (storage, , raise_exceptions) }.compact.to_json end |