Sha256: 5abb22095541f6832555bf49f9c8c51fed7b6ab5b506e8b1d501def515328ef4

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

#!/usr/bin/env ruby

require 'fog'
connection_opts = {
    :rackspace_username   => ENV['RAX_USERNAME'],
    :rackspace_api_key    => ENV['RAX_API_KEY'],
    :rackspace_region     => ENV['RAX_REGION'].downcase.to_sym,
    :rackspace_auth_url   => "#{ENV['RAX_AUTH_URL']}/v2.0"
}
storage = Fog::Storage.new(connection_opts.merge({:provider => 'rackspace'}))

container_name = 'my-site'
folder_to_upload = ENV['TEST_DIRECTORY']
username = ENV['RAX_USERNAME']
api_key = ENV['RAX_API_KEY']
auth_endpoint = ENV['RAX_AUTH_URL']

puts 'Uploading folder'
local_directory = Pathname.new folder_to_upload
remote_directory = storage.directories.create :key => container_name
Dir["#{folder_to_upload}/**.*"].each do |file|
  file_key = Pathname.new(file).relative_path_from local_directory
  remote_directory.files.create :key => file_key.to_s, :body => File.open(file)
end
puts 'Done uploading'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polytrix-0.0.1 sdks/fog/challenges/upload_folder.rb