Here’s the attachment definition that did this for me on my last project:
has_attached_file :file,
styles: { large: '620x410>' },
convert_options: { all: '-strip' },
s3_permissions: { original: :private },
s3_headers: {
'Cache-Control' => 'max-age=315576000',
'Expires' => 10.years.from_now.httpdate
},
path: 'public/system/:class/:hash.:extension',
url: '/system/:class/:hash.:extension',
hash_secret: 'really-long-random-generated-string-not-publicly-accessible'
The key is the :hash
interpolation and the :hash_secret
argument. Here’s the bit from the readme on this: GitHub - thoughtbot/paperclip: Easy file attachment management for ActiveRecord