module ActiveStorage::Blob::Identifiable

def download_identifiable_chunk

def download_identifiable_chunk
  if byte_size.positive?
    service.download_chunk key, 0...4.kilobytes
  else
    ""
  end
end

def identified?

def identified?
  identified
end

def identify

def identify
  unless identified?
    update! content_type: identify_content_type, identified: true
    update_service_metadata
  end
end

def identify_content_type

def identify_content_type
  Marcel::MimeType.for download_identifiable_chunk, name: filename.to_s, declared_type: content_type
end

def update_service_metadata

def update_service_metadata
  service.update_metadata key, service_metadata if service_metadata.any?
end