Hello, new to shrine here.
First want to thanks as it seems a really great gem. Congratulations!
I have some small issues though, I was trying to process a file reducing it’s dimensions if it’s greater than a value. My plan is change the original file, not store it as a “derivative”.
So after some reading found the processing plugin. In my uploader i have
class FileUploader < Shrine plugin :instrumentation plugin :determine_mime_type, analyzer: :marcel plugin :cached_attachment_data plugin :processing plugin :store_dimensions plugin :processing process(:store) do |io, context| io.download do |original| ImageProcessing::MiniMagick.source(original).resize_to_limit!(1920, 1920) end end end
Is this the right thing to do? I notice two things with this configuration.
The original file name of the file is lost. So instead of the image name uploaded (for example test.jpg) i end with something link image_processing20191026_xxxxx.jpg. If i don’t use the processing it stores the correct image.
So is there any way to retain the original filename when using the processing plugin.
Tried to use the process in a different action/phase (cache instead of store) but it seems not to be triggerd. What are the phases that the processing could be attached?
Last, one not so important question, is there any utility method to get what kind of “file” we are uploading? I mean something that for example could tell if we are uploading an image, so to only do the processing block if the uploaded file is an image, or triggering different block if it’s a video. I could develop one testing the mime types, asking just in case there is one already.
Thanks in advance