title: Node.js + Paperclip
body: <p>I have a Rails 4 application running on MongoDB and I use Paperclip (4.3) for the uploads. Everything works fine.</p>
  
  <p>Now I'm building a REST API with Node.js and Mongoose to serve some of the data and I'm having trouble understanding how I can generate the URL for the paperclip attachments with Node.js.</p>
  
  <p>Here's the relevant part of one of the Rails models:</p>
  
  <pre><code>has_mongoid_attached_file :thumb,
    :url  =&gt; "/assets/images/templates/:hash.:extension",
    :path =&gt; ":rails_root/public/assets/images/templates/:hash.:extension",
    :hash_secret =&gt; "somesecret"
  </code></pre>
  
  <p>The fields generated in the MongoDB document end up looking something like this:</p>
  
  <pre><code>"thumb_file_name" : "test-19103515.jpg",
  "thumb_content_type" : "image/jpeg",
  "thumb_file_size" : 76864,
  "thumb_fingerprint" : "00dab4127977a69ab264d79202f5f799",
  "thumb_updated_at" : ISODate("2018-03-28T03:32:36.454Z"),
  </code></pre>
  
  <p>and the URL of the file looks like this:</p>
  
  <pre><code>/assets/images/templates/3666b3ef97b492b27b108fd215c397d2435d5fcb.jpg?1522207956
  </code></pre>
  
  <p>Basically what I am asking is if anyone know how to generate the hash that paperclip generates so that given the hash_secret i can get in this case the resulting <code>3666b3ef97b492b27b108fd215c397d2435d5fcb</code> hash.</p>
  
  <p>Note that I am aware that there is a node-paperclip npm package but I only see there upload examples while what i need is to be able to generate the full URL of an attachment already uploaded by the Rails app. If by any chance one of you knows how to do that with that package I'll be happy to use it.</p>