Hi,
I Have download controller in my application.. In that i have def download_ordered_songs method, in that i have given my # AWS::S3::Base.establish_connection!( # :access_key_id => 'Put your Access Key ID Here', # :secret_access_key => 'Put your Secred Access Key here' # )
and the codings related to
@files = File.all
dir = "#{Time.now.to_date}-#{order.id}"
if Dir["/var/www/my-web-site/shared/songs/#{dir}"].empty? Dir.mkdir("/var/www/my-web-site/shared/songs/#{dir}") end path = "/var/www/my-web-site/shared/songs/#{Time.now.to_date}-#{order.id}"
if (file_size = File.size(mp3_path)) >= (original_file_size = AWS::S3::S3Object.find(song.full_track,"#{b_name}").size) downloadable.update_attribute(:was_downloaded,true) send_file(mp3_path, :disposition => 'attachment', :encoding => 'utf8') else downloadable.update_attribute(:error, "File size was supposed to be #{original_file_size} but was #{file_size}") end rescue Exception => e p "//////////////////////////////////////Error** #{e.message} **" flash[:error] = e.message redirect_to order_path(:id => params[:order_id]) end