You can use the `.preview` method on Active Storage objects (which contain a PDF or videos) to create image previews of the content within the file.
It's really fun to use, plus it only requires a few lines of code to get setup. It does require installing Poppler (for PDF previews) and FFmpeg (for video previews) which I'll covered in the video.
Sources
Sample Files: https://github.com/MikeRogers0-YouTub...
ActiveStorage::Preview Documentation: https://api.rubyonrails.org/v6.1.0/cl...
Poppler: https://en.wikipedia.org/wiki/Poppler...)
FFmpeg: https://en.wikipedia.org/wiki/FFmpeg
Heroku Active Storage Buildpack: https://github.com/heroku/heroku-buil...
Chapters
0:00 - What are we going to do?
0:18 - What happens if we upload a PDF?
1:03 - Which libraries do we need to install?
2:02 - Installing poppler-util & ffmpeg
3:03 - Uploading PDFs, videos & images
5:16 - The Heroku Buildpack
5:37 - Summary & Thank you
Support Me
/ mikerogers0
https://mikerogers.io
https://www.buymeacoffee.com/MikeRogers0
#ActiveStorage
#RubyOnRails
#PDFPreview