Class: DropboxExt::ItemsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DropboxExt::ItemsController
- Defined in:
- app/controllers/dropbox_ext/items_controller.rb
Instance Method Summary collapse
Instance Method Details
#dropbox ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/controllers/dropbox_ext/items_controller.rb', line 6 def dropbox if @dropbox return @dropbox end require 'dropbox' @dropbox = Dropbox::Client.new(params[:dbt]) end |
#sync ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/dropbox_ext/items_controller.rb', line 31 def sync items = params[:items] auth_params = params[:auth_params] if items && items.length > 0 items.each do |item| payload = { "items" => [item]} payload["auth_params"] = auth_params if auth_params != nil dropbox.upload("/data/#{item[:content_type]}-#{item[:uuid]}.txt", "#{JSON.pretty_generate(payload.as_json)}", {:mode => "overwrite"}) end end self.sync_decrypt_file() render :json => {:success => true} end |
#sync_decrypt_file ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/dropbox_ext/items_controller.rb', line 15 def sync_decrypt_file existing = dropbox.search("", "decrypt") if existing.length > 0 file = existing[0] days_old = (Time.now - file.client_modified).to_i / (24 * 60 * 60) if days_old < 14 return end end require 'open-uri' content = open('https://raw.githubusercontent.com/standardfile/decrypt-html-page/master/decrypt.html').read dropbox.upload("/decrypt.html", content, {:mode => "overwrite"}) end |