Sha256: fb2e8b8ef65629a673aaa225edde85e935076601b76257ebb5535b52f5f5e6c6
Contents?: true
Size: 1.85 KB
Versions: 5
Compression:
Stored size: 1.85 KB
Contents
# Call with DelayedJob.new.process_asset_images(...) # Run jobs locally with "rake jobs:work" module Effective class DelayedJob def process_asset(obj) if obj.kind_of?(Effective::Asset) asset = obj else asset = Effective::Asset.where(:id => (obj.to_i rescue 0)).first end if asset.present? && !asset.processed? && asset.upload_file.present? && asset.upload_file != 'placeholder' puts "Processing asset ##{asset.id} from #{asset.upload_file}." if asset.upload_file.include?(Effective::Asset.string_base_path) puts "String-based Asset processing and uploading..." asset.data.cache_stored_file! asset.data.retrieve_from_cache!(asset.data.cache_name) asset.data.recreate_versions! elsif asset.upload_file.include?(Effective::Asset.s3_base_path) puts "S3 Uploaded Asset downloading and processing..." # Carrierwave must download the file, process it, then upload the generated versions to S3 # We only want to process if it's an image, so we don't download zips or videos asset.remote_data_url = asset.url if asset.image? else puts "Non S3 Asset downloading and processing..." puts "Downloading #{asset.url}" # Carrierwave must download the file, process it, then upload it and generated verions to S3 # We only want to process if it's an image, so we don't download zips or videos asset.remote_data_url = asset.upload_file end asset.processed = true asset.save! (GC.start rescue nil) puts "Successfully processed the asset." end end handle_asynchronously :process_asset def reprocess_asset(id) Effective::Asset.find(id).reprocess! (GC.start rescue nil) end handle_asynchronously :reprocess_asset end end
Version data entries
5 entries across 5 versions & 1 rubygems