6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/active_storage/async_variants/callbacks_controller.rb', line 6
def create
variant_record_id = ActiveStorage.verifier.verify(params[:token], purpose: :async_variant_callback)
variant_record = ActiveStorage::VariantRecord.find(variant_record_id)
case params[:status]
when "success"
variant_record.update!(state: "processed")
apply_reported_metadata(variant_record, params)
when "progress"
ActiveStorage::VariantRecord
.where(id: variant_record.id, state: %w[pending processing])
.update_all(progress: params[:percent].to_i.clamp(0, 100), last_heartbeat_at: Time.current)
when "failed"
variant_record.update!(state: "failed", error: params[:error].to_s.truncate(16_000))
else
head :unprocessable_entity and return
end
head :ok
rescue ActiveSupport::MessageVerifier::InvalidSignature
head :unauthorized
end
|