Integrating Google Drive file uploads and display in Laravel Filament

Hey everyone, I’m trying to figure out if it’s possible to use Laravel Filament to handle file uploads directly to Google Drive. Here’s what I’m hoping to do:

  1. Use Filament’s file upload form builder to let users upload multiple files
  2. Instead of storing these files locally, send them straight to Google Drive
  3. Fetch the uploaded files from Google Drive
  4. Show these files in an iframe on a separate page in my Filament admin panel

Has anyone done something like this before? I’m not sure if Filament can work with Google Drive out of the box, or if I need to write some custom code to make this happen. Any tips or pointers would be super helpful!

Also, if there’s a better way to approach this whole thing, I’m all ears. Thanks in advance for any help!

I’ve actually tackled a similar project recently, and while it’s not straightforward, it’s definitely doable. You’ll need to leverage the Google Drive API and create some custom components in Filament.

First, set up Google Drive API credentials and integrate the PHP client library. Then, create a custom FileUploader that extends Filament’s default one, overriding the ‘upload’ method to push files to Drive instead of local storage.

For displaying files, I found it easiest to create a custom Filament page. Fetch the file metadata from Drive, then use Drive’s built-in viewer by embedding its URL in an iframe.

The trickiest part was handling OAuth2 authentication smoothly. I ended up storing refresh tokens in the database and implemented a middleware to handle token refreshes automatically.

It took some trial and error, but the end result was pretty slick. Users could upload and view files seamlessly, all within the Filament admin panel.

hey, i’ve done smth similar. u’ll need to use google drive API and make custom stuff in filament. create a custom uploader that sends files to drive. for showing files, make a custom page in filament that gets file info from drive and puts it in an iframe. the auth part can be tricky, but once u figure it out its not too bad. good luck!

I implemented a similar integration where I combined Filament with Google Drive. I had to write some custom code because Filament doesn’t support Google Drive out of the box. In my project I used the Google Drive API PHP Client Library to manage file operations and developed a custom uploader to transfer files directly to Google Drive instead of storing them locally. Moreover, I created a custom page in the admin panel that fetched file details and displayed them through an iframe. Handling authentication with Google Drive was probably the biggest hurdle, but once that was resolved, synchronizing uploads and display became much more straightforward.