shrinerb / shrine

File Attachment toolkit for Ruby applications
https://shrinerb.com
MIT License
3.17k stars 274 forks source link

Support retries with remote_url #649

Closed jeremylynch closed 1 year ago

jeremylynch commented 1 year ago

We are successfully using the remote_url, however occasionally running into "remote file not found" errors.

Is there a way we could pass a retries variable to the downloader? Or alternatively what is the recommended way to handle retries here?

janko commented 1 year ago

You can override the :downloader option to add your retry logic:

Shrine.plugin :remote_url, downloader: -> (url, **options) do
  # example using the retriable gem – https://github.com/kamui/retriable
  Retriable.retriable { Down.download(url, **options) }
end