I am building a web application where users can upload files to my server. The frontend is built with React, and the backend uses PHP. Instead of having users upload files directly, I want to allow them to share a Google Drive folder link.
The workflow would be:
- Users input a shared Google Drive folder link (e.g.,
https://drive.google.com/drive/folders/13KZQBFDkv1GijU9IhZCzwwM9cqvPPT-C?usp=sharing
). - My PHP backend fetches and downloads all the contents of that folder.
- The files are saved to a specific directory on my server, and a list of file names is returned to the frontend.
Challenges:
- I don’t want to use the Google Drive API because fetching all folders via the API would slow down the application significantly.
- I need a way to download files from a shared folder link without requiring users to authenticate or provide access tokens.
Question:
How can I programmatically fetch and download all the files from a shared Google Drive folder in PHP, given just the shared folder link? If direct access isn’t possible, what would be the best alternative approach to achieve this?
What I’ve Tried:
I’ve looked into parsing the shared folder link and making HTTP requests to Google Drive URLs, but it seems the folder contents are not directly accessible without using the API or user authentication.
Any guidance, code snippets, or alternative solutions would be greatly appreciated!