I have a simple model with an attached image using paperclip, which has a couple of processed styles for it (thumbnail, full, feature). At this point it works as it should, and makes a directory structure for each object in /public/assets/foo/
, containing subdirectories for original, thumbnail, full, and feature.
I don't want the original (high resolution) images to be exposed for users to obtain. So I'm hoping there is a way to specify a different path to store the originals somewhere outside of /public/
. Ideally paperclip should still be able to reprocess the styles using that original image as the source, as it does currently.
I'm also open to alternative suggestions for making the originals inaccessible to outside users. Whatever is the most practical solution here. Thanks.
I would recommend using a custom interpolation that will place your original files outside the public directory. Something like this:
Paperclip.interpolates :maybe_public do |attachment, style|
style == :original ? "private" : "public"
end
has_attached_file :image, :path => ":rails_root/:maybe_public/:attachment..."
This will save your :original files in a non-publicly accessible directory for protection, but still allow Paperclip access. And it will keep your thumbnails in the public directory for standard access.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With