Sha256: c0eb9582d1834f6e5964fe0bfbcc8640387c88c8726952721603958db0c6b61e

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

require_relative 'base_middleware'

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

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gooddata-bricks-0.8.0 lib/gooddata/bricks/middleware/fs_upload_middleware.rb
gooddata-bricks-0.7.0 lib/gooddata/bricks/middleware/fs_upload_middleware.rb
gooddata-bricks-0.6.0 lib/gooddata/bricks/middleware/fs_upload_middleware.rb
gooddata-bricks-0.5.0 lib/gooddata/bricks/middleware/fs_upload_middleware.rb
gooddata-bricks-0.4.0 lib/gooddata/bricks/middleware/fs_upload_middleware.rb
gooddata-bricks-0.3.0 lib/gooddata/bricks/middleware/fs_upload_middleware.rb
gooddata-bricks-0.2.0 lib/gooddata/bricks/middleware/fs_upload_middleware.rb
gooddata-bricks-0.1.0 lib/gooddata/bricks/middleware/fs_upload_middleware.rb