Very cool! Can you dedicate an episode to playing public audiofiles (uploaded through Active Storage) directly from the S3 bucket (and not through the application)?
You can use @podcast.audio.service_url instead of url_for(@podcast.audio) which will be a direct link to the S3 endpoint. However, if you're using a different storage mechanism like disk in your development environment, it wouldn't work. You may need to have minio or something similar within your development environment.
almokhtar I would say that it’s possible. SoundWave gives enough flexibility with its APIs but is somewhat limited on the customization. For a true customization, Howler is pretty powerful. However, you would basically be building your own custom UI for it.
How can I secure active storage file in the browser HTML mark-up?
Below generates when I inspect the browser. And, the file downloads right away when you click on the link in the HTML mark-up. Meaning anyone can download uploaded files although it can not be downloaded directly from the front end.
charliewiredu Check out the video on streaming videos where it shows how to use the controller to send the Active Storage url instead of having it embed within the view. This may help protect the link as it is then able to be authenticated and authorized via the controller. https://www.driftingruby.com/episodes/streaming-videos-with-active-storage
@podcast.audio.service_url
instead ofurl_for(@podcast.audio)
which will be a direct link to the S3 endpoint. However, if you're using a different storage mechanism likedisk
in your development environment, it wouldn't work. You may need to haveminio
or something similar within your development environment.https://howlerjs.com/
howler.js - JavaScript audio library for the modern web
howler.js makes working with audio in JavaScript easy and reliable across all platforms.
https://howlerjs.com/
Below generates when I inspect the browser. And, the file downloads right away when you click on the link in the HTML mark-up.
Meaning anyone can download uploaded files although it can not be downloaded directly from the front end.
<a href="/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWTA9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--7d855c7bea95a43128ac7549fee0f2e6d9e172c4/testing-security.mp3" class="">
<span id="play" style="">
<i class="fa fa-play" aria-hidden="true"></i>
Play
</span>
</a>
Episode 230 - Streaming Videos with Active Storage
Video.js is a web video player built from the ground up for an HTML5 world. Learn how to use it with StimulusJS and Active Storage to deliver video content from your Ruby on Rails application.
https://www.driftingruby.com/episodes/streaming-videos-with-active-storage