Sha256: ed866ab0f2494e6b8605e22026721d983dbec55d757386b3ccb0e38e3946cb24

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 Bytes

Contents

# encoding: UTF-8
require_relative 'base_middleware'

module GoodData
  module Bricks
    class FsProjectUploadMiddleware < Bricks::Middleware
      def initialize(options = {})
        super
        @destination = options[:destination]
      end

      def call(params)
        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)
              puts "Uploaded local file \"#{path}\" to url \"#{url + path}\""
            end
          end
        end
      end
    end
    FsUploadMiddleware = FsProjectUploadMiddleware
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gooddata-0.6.20 lib/gooddata/bricks/middleware/fs_upload_middleware.rb
gooddata-0.6.19 lib/gooddata/bricks/middleware/fs_upload_middleware.rb
gooddata-0.6.18 lib/gooddata/bricks/middleware/fs_upload_middleware.rb
gooddata-0.6.17 lib/gooddata/bricks/middleware/fs_upload_middleware.rb
gooddata-0.6.16 lib/gooddata/bricks/middleware/fs_upload_middleware.rb