Module: Technoweenie::AttachmentFu::Backends::AppEngineBackend
- Defined in:
- lib/technoweenie/attachment_fu/backends/app_engine_backend.rb
Overview
store in Google App Engine
Constant Summary collapse
- @@base_url =
"http://attachment-fu-gae.appspot.com"- @@storage_prefix =
nil
Instance Method Summary collapse
- #create_or_update_thumbnail(*args) ⇒ Object
- #create_temp_file ⇒ Object
-
#current_data ⇒ Object
Gets the current data from the database.
-
#full_filename ⇒ Object
The full path to the file relative to the bucket name Example:
:table_name/:id/:filename. -
#process_attachment ⇒ Object
TODO: HACK??.
- #public_filename(thumbnail = nil) ⇒ Object
Instance Method Details
#create_or_update_thumbnail(*args) ⇒ Object
51 52 53 |
# File 'lib/technoweenie/attachment_fu/backends/app_engine_backend.rb', line 51 def create_or_update_thumbnail(*args) #ignore end |
#create_temp_file ⇒ Object
28 29 30 |
# File 'lib/technoweenie/attachment_fu/backends/app_engine_backend.rb', line 28 def create_temp_file write_to_temp_file current_data end |
#current_data ⇒ Object
Gets the current data from the database
33 34 35 36 37 38 |
# File 'lib/technoweenie/attachment_fu/backends/app_engine_backend.rb', line 33 def current_data uri = URI.parse(AppEngineBackend.base_url) Net::HTTP.new(uri.host, uri.port).start do |http| http.get(filename).response_body end end |
#full_filename ⇒ Object
The full path to the file relative to the bucket name Example: :table_name/:id/:filename
47 48 49 |
# File 'lib/technoweenie/attachment_fu/backends/app_engine_backend.rb', line 47 def full_filename ['attachments', storage_prefix, [:path_prefix].gsub('public/', ''), id.to_s, filename].compact.join('/') end |
#process_attachment ⇒ Object
TODO: HACK??
41 42 43 |
# File 'lib/technoweenie/attachment_fu/backends/app_engine_backend.rb', line 41 def = true end |
#public_filename(thumbnail = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/technoweenie/attachment_fu/backends/app_engine_backend.rb', line 13 def public_filename(thumbnail = nil) thumbnails = HashWithIndifferentAccess.new([:thumbnails]) query = if thumbnail && thumbnails[thumbnail] "?resize=#{thumbnails[thumbnail]}" elsif thumbnail.is_a?(String) "?resize=#{thumbnail}" elsif [:resize] "?resize=#{attachment_options[:resize]}" else '' end "#{AppEngineBackend.base_url}/#{full_filename}#{query}" end |