Class: DropboxExt::ItemsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/dropbox_ext/items_controller.rb

Instance Method Summary collapse

Instance Method Details

#dropboxObject



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

#syncObject



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/dropbox_ext/items_controller.rb', line 15

def sync
  items = params[:items]
  if items && items.length > 0
    items.each do |item|
      dropbox.upload("/data/#{item[:content_type]}-#{item[:uuid]}.txt", "#{JSON.pretty_generate(item.as_json)}", {:mode => "overwrite"})
    end
  end

  render :json => {:success => true}
end