(Active Storage) How to check for an existing blob in another AWS bucket?
Hi there,
I'm trying to do something quite simple, which is:
- A user uploads a video to a chat (a message can have many attachments)
- The video uploaded automatically gets transcoded with Elastic Transcoder if it is a video
- The use on the receiving end receives the message along with the attachments instantly streamed via turbo
So far what I got working:
- Users can upload attachments and they are instantly streamed via turbo
- An AWS lambda function that triggers Elastic Transcoder to transcode a video whenever a new file is uploaded into my S3 bucket
What I'm stuck on / Questions I have:
- How do I retrieve the new transcoded video in the new S3 bucket from rails? (Currently the key is the same with an added prefix of the file type eg: mp4_blobkeyhere
- How can I prevent the message from being sent until after the transcode job is complete?
- Is using lambda even best practice here, or should I be calling for this job to be completed from my server?
I would really appreciate if anyone has any input into this situation.
Thanks!
AWS should provide a webhook that you'll need to listen to once the file is finished transcoding. You can use that to trigger a broadcast of the final video with Turbo.
Transcoding is a messy art though, so I would recommend trying out something like Mux, Bunny Stream or Cloudflare Stream if you can. They usually do on-the-fly transcoding so you can instantly embed the video which is really nice. I believe you can do the same with AWS too, but it's the usual digging through config and docs to figure out how to do it.