class GoodData::Bricks::FsUploadMiddleware

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method GoodData::Bricks::Middleware::new
# File lib/gooddata/bricks/middleware/fs_upload_middleware.rb, line 12
def initialize(options = {})
  super
  @destination = options[:destination]
end

Public Instance Methods

call(params) click to toggle source
# File lib/gooddata/bricks/middleware/fs_upload_middleware.rb, line 17
def call(params)
  params = params.to_hash
  returning(@app.call(params)) do |_|
    destination = @destination
    (params['gdc_files_to_upload'] || []).each do |f|
      path = f[:path]
      case destination.to_sym
      when :staging
        GoodData.client.get '/gdc/account/token', dont_reauth: true
        url = GoodData.project_webdav_path
        GoodData.upload_to_project_webdav(path)
        GoodData.logger.info("Uploaded local file \"#{path}\" to url \"#{url + path}\"")
      end
    end
  end
end