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
- .access_key ⇒ Object
-
.asset_url_prefix ⇒ Object
Returns the value of attribute asset_url_prefix.
-
.host ⇒ Object
Returns the value of attribute host.
-
.path_prefix ⇒ Object
Returns the value of attribute path_prefix.
-
.port ⇒ Object
Returns the value of attribute port.
- .secret_key ⇒ Object
-
.session_timeout ⇒ Object
Returns the value of attribute session_timeout.
-
.upload_url ⇒ Object
Returns the value of attribute upload_url.
-
.use_ssl ⇒ Object
Returns the value of attribute use_ssl.
Class Method Summary collapse
- .default_asset_url_prefix ⇒ Object
- .default_upload_url ⇒ Object
- .generate_auth_token ⇒ Object
- .generate_download_auth_token(file_id) ⇒ Object
- .generate_upload_auth_token(uploader) ⇒ Object
- .url_prefix ⇒ Object
Class Attribute Details
.access_key ⇒ Object
8 9 10 |
# File 'lib/filer/config.rb', line 8 def access_key @access_key || ENV['PROGSTR_FILER_ACCESS_KEY'] end |
.asset_url_prefix ⇒ Object
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 |
.host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/filer/config.rb', line 5 def host @host end |
.path_prefix ⇒ Object
Returns the value of attribute path_prefix.
5 6 7 |
# File 'lib/filer/config.rb', line 5 def path_prefix @path_prefix end |
.port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/filer/config.rb', line 5 def port @port end |
.secret_key ⇒ Object
12 13 14 |
# File 'lib/filer/config.rb', line 12 def secret_key @secret_key || ENV['PROGSTR_FILER_SECRET_KEY'] end |
.session_timeout ⇒ Object
Returns the value of attribute session_timeout.
5 6 7 |
# File 'lib/filer/config.rb', line 5 def session_timeout @session_timeout end |
.upload_url ⇒ Object
Returns the value of attribute upload_url.
5 6 7 |
# File 'lib/filer/config.rb', line 5 def upload_url @upload_url end |
.use_ssl ⇒ Object
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_prefix ⇒ Object
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_url ⇒ Object
30 31 32 |
# File 'lib/filer/config.rb', line 30 def default_upload_url "http://#{Progstr::Filer.host}/upload/new" end |
.generate_auth_token ⇒ Object
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 |