We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Andrea Fomera - Pushing the boundaries with ActiveStorage - Rails World 2024
Learn how to extend ActiveStorage beyond cloud storage, integrate third-party services like Wistia and Pexels, and implement custom providers in this Rails World 2024 talk.
-
ActiveStorage can be extended beyond traditional cloud storage providers to integrate with third-party services like Wistia and Pexels
-
Custom providers can be implemented by:
- Inheriting from ActiveStorageService
- Implementing key methods: upload, delete, download, download_chunk, and public
- Adding provider hooks to handle different file sources
-
Using the
providers
keyword argument to specify available providers
-
Media library functionality can be added by:
- Adding a user_id column to active_storage_attachments
- Creating scopes for filtering and searching blobs
- Implementing file name search functionality
- Building a UI for users to manage their uploads
-
Tracking user uploads requires:
- Adding a reference to users in the active_storage_attachments table
- Including concerns to automatically set user associations
- Implementing proper scoping for user-specific queries
-
Integration with third-party services:
- Wistia for video hosting
- Pexels for stock images
- Custom handling of file uploads through service-specific APIs
- Parsing and storing service-specific metadata
-
Performance considerations:
- Avoiding duplicate blob creation for identical files
- Handling deletions through background jobs
- Managing file variations and thumbnails efficiently
- Implementing proper scoping for large file collections
-
Security considerations:
- Using expiring tokens for authentication
- Implementing proper access controls
- Managing public vs private file access
- Securing API integrations