Skip to content

Instantly share code, notes, and snippets.

@Veejay
Created April 23, 2014 10:21
Show Gist options
  • Save Veejay/129bec8be75ca4bcbc6b to your computer and use it in GitHub Desktop.
Save Veejay/129bec8be75ca4bcbc6b to your computer and use it in GitHub Desktop.
upload_sizes.rb
def upload_sizes(paths, filename, extension)
rails_root = Pathname.new(Rails.root)
[].tap do |threads|
paths.each do |hash|
container = Site.current.container
threads << Thread.new do
body = File.read(hash[:path])
rackspace_file = container.files.create(
key: "files/#{self.id}/#{hash[:path]}",
body: body
)
rails_root.join(hash[:path]).delete
keys.store(hash[:size].to_sym, rackspace_file.key)
end
end
end.each(&:join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment