title: How can I verify that an ActiveStorage blob is actually present?
body: <p>I've got an application that's been running in production for many months now, with tens of thousands of attachments. This morning, I tried to do an operation on one of these attachments, and got the following error:</p>
  
  <pre><code>Azure::Core::Http::HTTPError: BlobNotFound (404): The specified blob does not exist.
  </code></pre>
  
  <p>I can easily recreate this blob, but this situation makes me want to write a script to check the integrity of <em>all</em> of my attachments, and verify that no others have gone missing. (I expect that this was a transitory network error, and I expect to find very few, but I need the peace of mind.)</p>
  
  <p>I can see that there is a method to call that seems to do exactly what I need: <code>exist?(key)</code>, which is documented here: </p>
  
  <p><a href="https://github.com/rails/rails/blob/master/activestorage/lib/active_storage/service/disk_service.rb" rel="nofollow noreferrer">https://github.com/rails/rails/blob/master/activestorage/lib/active_storage/service/disk_service.rb</a></p>
  
  <p>However, I can't figure out how I'm supposed to call it. According to <a href="https://api.rubyonrails.org/classes/ActiveStorage/Service.html#method-i-exist-3F" rel="nofollow noreferrer">this</a>, it's implemented as an instance method. So how do I reference my Rails application's active ActiveStorage <em>instance</em> (depending on environment) to use this method? </p>