class Avo::Fields::Common::SingleFileViewerComponent
def destroy_path
def destroy_path Avo::Services::URIService.parse(@resource.record_path).append_paths("active_storage_attachments", id, file.id).to_s end
def file
def file @file || field.value.attachment rescue nil end
def id
def id field.id end
def initialize(field:, resource:, file: nil)
def initialize(field:, resource:, file: nil) @file = file @field = field @resource = resource end
def is_audio?
def is_audio? file.audio? || field.is_audio rescue false end
def is_image?
def is_image? file.image? || field.is_image rescue false end
def is_video?
def is_video? file.video? || field.is_video rescue false end
def record_persisted?
def record_persisted? return true if @resource.record.persisted? ActiveStorage::Blob.destroy(file.blob_id) if file.blob_id.present? false end
def render?
def render? record_persisted? end