I have a Rails app that uploads a video to an s3 bucket which triggers a Lambda function to do some processing on the videos and store them in another bucket.
I'd like to alter my Rails code so that these processed videos can be shown.
I'm currently using ActiveStorage and I understand that this doesn't support multiple buckets so I'd like to know which service supports this functionality and the best approach to take
This answer points to something similar with changing file paths with carrierwave, fog and cloudfront but I'm a beginner coder so not sure I can hack it to my needs... Use CDN with carrierwave + fog in s3 + cloudfront with rails 3.1
Any suggestions of direction would be appreciated
My Solution I've hacked a solution, which is to just access the processed video's directly. If its dumb but it works, then it ain't dumb!:
@aws_url = @gif.video.attachment.service_url.sub(/\?.*/, '')
@aws_url = @aws_url.insert(21, '-resized')
@aws_url = @aws_url + '.mp4'
Here I set @aws_url
in the controller's show method to equal the service_url
minus the superfluous code.
Then I inserted -resized
into the string so that the correct s3 bucket name is referenced in the string.
Lastly I appended .mp4
to the end because all of the processed videos are mp4s.
To get this to work I made the bucket public read-only, which probably isn't the best thing but meh