Class: OracleHcm::Attachment

Inherits:
Resource show all
Defined in:
lib/oracle_hcm/attachment.rb

Overview

An Attachment is a child resource of a Document Record (or Document of Record), and stores upload file data and metadata.

Instance Attribute Summary

Attributes inherited from Resource

#client, #data, #parent

Instance Method Summary collapse

Methods inherited from Resource

cached_property, #canonical_id, child_resource, #initialize, #link, property, #resource_name, resource_name, #resource_url, #uri

Constructor Details

This class inherits a constructor from OracleHcm::Resource

Instance Method Details

#downloadObject

Download the file via a readable IO object.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/oracle_hcm/attachment.rb', line 13

def download
  io = StringIO.new
  res = client.connection.get do |req|
    req.url uri(rel: "enclosure")
    req.options.on_data = Proc.new do |chunk, total_bytes|
      io << chunk
    end
  end
  if res.success?
    io.rewind
    io
  else
    nil
  end
end