How do I open a file on Amazon S3 and authenticate?
I know how to do this with paperclip, but how is it done when having to open file?
My helper
File.open("#{RAILS_ROOT}/public/xml/#{output}.xml", "w") do |f|
f.puts("<?xml version='1.0' encoding='UTF-8'?>")
f.puts("<site>")
f.puts("<general name='general' type='general'><imagePath>photographer/image/</imagePath><moviePath>../photographer/flv/</moviePath></general>")
f.puts("#{xmlmenu.to_xml}")
f.puts("#{xmlmovies.to_xml}")
f.puts("#{xmltextpages.to_xml}")
f.puts("</site>")
end
UPDATE
My helper file:
module Admin::XmlHelper
require 'builder'
require 'aws/s3'
def update_xml(output)
AWS::S3::Base.establish_connection!(
:access_key_id => 'mykey',
:secret_access_key => 'mykey'
)
file = "xml/#{output}.xml"
content = "#{
f.puts("<?xml version='1.0' encoding='UTF-8'?>")
f.puts("<site>")
f.puts("<general name='general' type='general'><imagePath>photographer/image/</imagePath><moviePath>../photographer/flv/</moviePath></general>")
f.puts("#{xmlmenu.to_xml}")
f.puts("#{xmlmovies.to_xml}")
f.puts("#{xmltextpages.to_xml}")
f.puts("</site>")}"
AWS::S3::S3Object.store(file, content, "mybucket", :access => :public_read)
end
end
I get the error in view:
uninitialized constant AWS::S3::Base
http://pastie.org/2587071
Update:
Instead of gem "aws-s3"
Should it be: gem 'aws-s3', :require => 'aws/s3'