Replies: 1 comment 1 reply
-
Hi @renchap, you probably already managed to write some integration code, but in case it helps, shrine-transloadit is an example of using an external service to do the processing, then building uploaded file objects from the response. You can take a look at the source code to see how this is implemented. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an uploader that processes image & video files, with a somewhat complex configuration: derivatives,
determine_mime_type
,store_dimensions
, severaladd_metadata
…Shrine is configured with backgrounding using Sidekiq:
The derivatives & metadata extractions have 2 paths depending if the file is an image or a video.
As we get more and more videos, I would like to use an external service for video metadata extraction, derivatives generation and thumbnailing. https://www.coconut.co does this all at a cheap price, so this is my choice for now.
I am unsure on how to properly implement this. I have the code to send jobs to Coconut (giving them a list of formats I want, and signed URIs to upload the files to) and I can receive their callback on an URL once the job is done.
I store the mime type when creating the record, so this information is present before any processing (no need for
determine_mime_type
, this is currently only used as a security against spoofing).So I need Shrine to somehow detect (before processing) that this file is a video, and then dont process it further but creates a Coconut job for it. Is this doable with Shrine? Should it be implemented in the
ShrinePromoteWorker
, for exampleattacher.submit_to_coconut if attacher.use_coconut?
?Then I guess I can have a custom controller getting the Coconut payload and updating the record directly, writing the correct fields? Or is it a better way?
Beta Was this translation helpful? Give feedback.
All reactions