Class: Opener::Daemons::Uploader
- Inherits:
-
Object
- Object
- Opener::Daemons::Uploader
- Defined in:
- lib/opener/daemons/uploader.rb
Overview
Class for uploading KAF documents to Amazon S3.
Instance Method Summary collapse
- #bucket ⇒ Aws::S3::Bucket
- #create(key, body, options = {}) ⇒ Aws::S3::Object
- #s3 ⇒ Aws::S3::Resource
-
#upload(identifier, document, metadata = {}) ⇒ Aws::S3::Object
Uploads the given KAF document.
Instance Method Details
#bucket ⇒ Aws::S3::Bucket
44 45 46 |
# File 'lib/opener/daemons/uploader.rb', line 44 def bucket @bucket ||= s3.bucket(Daemons.output_bucket) end |
#create(key, body, options = {}) ⇒ Aws::S3::Object
34 35 36 |
# File 'lib/opener/daemons/uploader.rb', line 34 def create(key, body, = {}) bucket.put_object(.merge(:key => key, :body => body)) end |
#s3 ⇒ Aws::S3::Resource
39 40 41 |
# File 'lib/opener/daemons/uploader.rb', line 39 def s3 @s3 ||= Aws::S3::Resource.new end |
#upload(identifier, document, metadata = {}) ⇒ Aws::S3::Object
Uploads the given KAF document.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/opener/daemons/uploader.rb', line 12 def upload(identifier, document, = {}) = {} .each do |key, value| [key.to_s] = value.to_s end object = create( "#{SecureRandom.hex}/#{identifier}.xml", document, :metadata => , :content_type => 'application/xml', :acl => 'public-read' ) return object end |