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

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_fileObject



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_dataObject

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_filenameObject

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, attachment_options[:path_prefix].gsub('public/', ''), id.to_s, filename].compact.join('/')
end

#process_attachmentObject

TODO: HACK??



41
42
43
# File 'lib/technoweenie/attachment_fu/backends/app_engine_backend.rb', line 41

def process_attachment
  @saved_attachment = 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(attachment_options[:thumbnails])

  query = if thumbnail && thumbnails[thumbnail]
    "?resize=#{thumbnails[thumbnail]}"
  elsif thumbnail.is_a?(String)
    "?resize=#{thumbnail}"
  elsif attachment_options[:resize]
    "?resize=#{attachment_options[:resize]}"
  else
    ''
  end
  "#{AppEngineBackend.base_url}/#{full_filename}#{query}"
end