shrinerb / shrine

File Attachment toolkit for Ruby applications

Home Page:https://shrinerb.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docs - missing link to https://shrinerb.com/docs/plugins/processing

jivko-chobanov opened this issue · comments

In the Plugins section of the docs there is a Processing heading with no link to https://shrinerb.com/docs/plugins/processing page. Under that heading there are two pages - Derivation Endpoint (with link) and Derivatives (with link). I expect that the Processing page is added to the Processing heading along with Derivation Endpoint and Derivatives in the leftside menu in Plugins section of the docs.

Hi, the link you posted refers to the processing plugin, which has been deprecated in Shrine 3.0 and shouldn't be linked to from anywhere anymore (that's why it's not listed in the plugins sidebar). There is a File Processing guide which aims to describe in high-level how processing works in Shrine (and mentions derivatives & derivation_endoint). Does that solve the confusion?

Hi, thank you for your help :) I was trying to find out what is the proper syntax for resizing jpg upload not as a derivative, but directly resizing the original file and then promoting it from :cache to :store. The File Processing guide talks mostly about derivatives. Then I found the deprecated processing plugin docs which start with:

"Shrine uploaders can define the #process method, which will get called whenever a file is uploaded. It is given the original file, and is expected to return the processed files."

That sentence exactly described what I was looking for. What is the non-deprecated way of doing it, i.e. instead of

class ProductImageUploader < Shrine
  ...
  process(:store) do |io, context|
    io.download do |original|
      ...
    end
  end
end

what should I write to resize without using derivatives?

Oh, I see, you want to replace the original file. Shrine doesn't offer a built-in solution for this anymore, because replacing the original file is now discouraged (since you cannot re-process the file later on if you need to). This thread discusses some possible solutions.