Class: ActiveStorage::CloudTransformations::Variant
- Inherits:
-
VariantWithRecord
- Object
- VariantWithRecord
- ActiveStorage::CloudTransformations::Variant
- Defined in:
- lib/active_storage/cloud_transformations/variant.rb
Instance Method Summary collapse
Instance Method Details
#process ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/active_storage/cloud_transformations/variant.rb', line 6 def process raise ActiveStorage::InvariableError unless blob.image? || blob.video? blob.variant_records.find_or_create_by!(variation_digest: variation.digest) do |record| output_blob = ActiveStorage::Blob.create_before_direct_upload!(**{ filename: "#{blob.filename.base}.#{variation.format}", content_type: variation.content_type, service_name: blob.service_name, byte_size: 0, # we don"t know this yet, can we get it from the results? checksum: 0, # we don"t know this yet, can we get it from the results? }) output_blob.[:analyzed] = true record.image.attach(output_blob) run_crucible_job(blob, output_blob, ignore_timeouts: true) ActiveStorage::AnalyzeJob.perform_later(output_blob) end rescue ActiveRecord::RecordNotUnique retry end |
#reprocess ⇒ Object
26 27 28 29 30 31 |
# File 'lib/active_storage/cloud_transformations/variant.rb', line 26 def reprocess raise ActiveStorage::InvariableError unless blob.image? || blob.video? record = blob.variant_records.find_by!(variation_digest: variation.digest) output_blob = record.image.blob run_crucible_job(blob, output_blob, ignore_timeouts: true) end |