class Opener::Daemons::Uploader
Class for uploading KAF documents to Amazon S3.
Public Instance Methods
bucket()
click to toggle source
@return [Aws::S3::Bucket]
# File lib/opener/daemons/uploader.rb, line 44 def bucket @bucket ||= s3.bucket(Daemons.output_bucket) end
create(key, body, options = {})
click to toggle source
@param [String] key @param [String] body @param [Hash] options @return [Aws::S3::Object]
# File lib/opener/daemons/uploader.rb, line 34 def create(key, body, options = {}) bucket.put_object(options.merge(:key => key, :body => body)) end
s3()
click to toggle source
@return [Aws::S3::Resource]
# File lib/opener/daemons/uploader.rb, line 39 def s3 @s3 ||= Aws::S3::Resource.new end
upload(identifier, document, metadata = {})
click to toggle source
Uploads the given KAF document.
@param [String] identifier @param [String] document @param [Hash] metadata description
@return [Aws::S3::Object]
# File lib/opener/daemons/uploader.rb, line 12 def upload(identifier, document, metadata = {}) converted_metadata = {} metadata.each do |key, value| converted_metadata[key.to_s] = value.to_s end object = create( "#{SecureRandom.hex}/#{identifier}.xml", document, :metadata => converted_metadata, :content_type => 'application/xml', :acl => 'public-read' ) return object end