Class: Boar::Handlers::Downloads::SkyDrive
- Defined in:
- app/models/boar/handlers/downloads/sky_drive.rb
Instance Attribute Summary
Attributes inherited from Base
Attributes inherited from Generic
Instance Method Summary collapse
- #call(path, entry, skip_cache, _, _) ⇒ Object
-
#initialize(service, options) ⇒ SkyDrive
constructor
A new instance of SkyDrive.
Methods inherited from Base
#class_key, #credentials_params, #finalize_path, #load_credentials, #update_credentials
Methods included from Utils::Basic
#ensure_hash, #get_option, #interpolate
Constructor Details
Instance Method Details
#call(path, entry, skip_cache, _, _) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/boar/handlers/downloads/sky_drive.rb', line 17 def call(path, entry, skip_cache, _, _) # Read the URL from Redis key = @configuration.backend_key("downloads:sky_drive[#{path}]", self, @service.controller.request) url = @configuration.backend.get(key) if skip_cache || url.blank? then begin # Get the file file = @client.get("/" + entry[:id]) rescue nil raise Boar::Exceptions::NotFound if file.blank? url = entry["disposition"] == "inline" ? file.link : file.download_link raise Boar::Exceptions::NotFound if url.blank? # Save the URL @configuration.backend.set(key, url) if url.present? rescue => e raise e raise Boar::Exceptions::ServerError.new("[#{e.class}] #{e.}") end end # Redirect to the final URL @service.controller.redirect_to(url) end |