Sha256: 1677ca35699d9bc458b6db0a916336475e6bae579a9f6ef8d991e66075035a00
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
namespace :uploads do task :migrate do files = Rails.root.join('public', 'uploads', 'files') images = Rails.root.join('public', 'uploads', 'images', 'original') ::FileUtils.mkdir_p files ::FileUtils.mkdir_p images Dir.glob(::File.join(Rails.root.join('public', 'uploads'), '', '*.*')) do |source| filename = ::File.basename(source) if filename =~ /-/ ::FileUtils.rm source elsif filename =~ /\.(jpg|png|gif)$/ ::FileUtils.mv source, ::File.join(images, filename) else filename =~ /\.!(htm|html|ico)$/ ::FileUtils.mv source, ::File.join(files, filename) end end end namespace :presets do desc 'Clean preset' task :clean, [:preset] do if ENV['NAME'].present? path = Rails.root.join('public', 'uploads', 'images', ENV['NAME']) ::FileUtils.rm_rf path if ::File.directory? path end end end namespace :s3 do namespace :buckets do desc 'Create buckets' task :create do config = YAML.load_file(Rails.root.join('config', 's3.yml')) config.each do |env, options| AWS.config access_key_id: options['access_key_id'], secret_access_key: options['secret_access_key'] bucket = options['bucket'] begin AWS::S3.new.buckets.create bucket rescue AWS::S3::Errors::InvalidAccessKeyId puts "Invalid credentials in #{env} environment." next rescue AWS::S3::Errors::BucketAlreadyExists puts "Bucket #{bucket} already exists." next rescue AWS::S3::Errors::BucketAlreadyOwnedByYou puts "You already own bucket #{bucket}." next end puts "Bucket #{bucket} created successfully." end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_uploads-0.2.0 | lib/tasks/rails_uploads_tasks.rake |