Module: Progstr::Filer

Defined in:
lib/filer/config.rb,
lib/filer/uploader.rb,
lib/filer/attachment.rb,
lib/filer/validation.rb,
lib/filer/views/html.rb,
lib/filer/activerecord.rb,
lib/filer/views/form_html.rb

Defined Under Namespace

Modules: ActiveRecordClassMethods, ActiveRecordInstanceMethods, FormHtml, Html, Validation Classes: Attachment, FileLike, UploadStatus, Uploader

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.access_keyObject



8
9
10
# File 'lib/filer/config.rb', line 8

def access_key
  @access_key || ENV['PROGSTR_FILER_ACCESS_KEY']
end

.asset_url_prefixObject

Returns the value of attribute asset_url_prefix.



5
6
7
# File 'lib/filer/config.rb', line 5

def asset_url_prefix
  @asset_url_prefix
end

.hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/filer/config.rb', line 5

def host
  @host
end

.path_prefixObject

Returns the value of attribute path_prefix.



5
6
7
# File 'lib/filer/config.rb', line 5

def path_prefix
  @path_prefix
end

.portObject

Returns the value of attribute port.



5
6
7
# File 'lib/filer/config.rb', line 5

def port
  @port
end

.secret_keyObject



12
13
14
# File 'lib/filer/config.rb', line 12

def secret_key
  @secret_key || ENV['PROGSTR_FILER_SECRET_KEY']
end

.session_timeoutObject

Returns the value of attribute session_timeout.



5
6
7
# File 'lib/filer/config.rb', line 5

def session_timeout
  @session_timeout
end

.upload_urlObject

Returns the value of attribute upload_url.



5
6
7
# File 'lib/filer/config.rb', line 5

def upload_url
  @upload_url
end

.use_sslObject

Returns the value of attribute use_ssl.



5
6
7
# File 'lib/filer/config.rb', line 5

def use_ssl
  @use_ssl
end

Class Method Details

.default_asset_url_prefixObject



20
21
22
23
24
25
26
27
28
# File 'lib/filer/config.rb', line 20

def default_asset_url_prefix
  insecure_prefix = "http://cdn.progstr.com/upload/"
  secure_prefix = "https://s3.amazonaws.com/cdn.progstr.com/upload/"
  javascript_version = "1.0"

  prefix = insecure_prefix
  prefix = secure_prefix if use_ssl
  prefix + javascript_version
end

.default_upload_urlObject



30
31
32
# File 'lib/filer/config.rb', line 30

def default_upload_url
  "http://#{Progstr::Filer.host}/upload/new"
end

.generate_auth_tokenObject



44
45
46
47
48
49
# File 'lib/filer/config.rb', line 44

def generate_auth_token
  expiration = expiration_time
  to_sign = "#{access_key}-#{expiration}-#{secret_key}"
  signature = Digest::SHA1.hexdigest(to_sign)
  "#{access_key}-#{expiration}-#{signature}"
end

.generate_download_auth_token(file_id) ⇒ Object



51
52
53
54
55
56
# File 'lib/filer/config.rb', line 51

def generate_download_auth_token(file_id)
  expiration = expiration_time
  to_sign = "#{access_key}-#{file_id}-#{expiration}-#{secret_key}"
  signature = Digest::SHA1.hexdigest(to_sign)
  "#{access_key}-#{expiration}-#{signature}"
end

.generate_upload_auth_token(uploader) ⇒ Object



58
59
60
61
62
63
# File 'lib/filer/config.rb', line 58

def generate_upload_auth_token(uploader)
  expiration = expiration_time
  to_sign = "#{access_key}-#{uploader}-#{expiration}-#{secret_key}"
  signature = Digest::SHA1.hexdigest(to_sign)
  "#{access_key}-#{expiration}-#{signature}"
end

.url_prefixObject



65
66
67
68
69
70
71
72
# File 'lib/filer/config.rb', line 65

def url_prefix
  prefix = "http://#{Progstr::Filer.host}:#{Progstr::Filer.port}#{Progstr::Filer.path_prefix}"
  if prefix.end_with? "/"
    prefix
  else
    prefix + "/"
  end
end