I’m trying to figure out if there’s a way to upload files to Google Drive directly from a web URL.
For instance, let’s say I have a document on my website at mysite.com/document.pdf. Is there some kind of Google Drive API or URL structure that would let me upload this file without downloading it first?
Does anyone know if this is possible? Or do I need to use a more complex method with the Google Drive API? Any tips or suggestions would be really helpful. I’m not super tech-savvy, so simpler solutions are preferred if they exist. Thanks!
I’ve found a workaround that might help you out. Instead of directly uploading to Google Drive, you can use a service like IFTTT (If This Then That) to create an applet. Set it up to monitor a specific web folder and automatically upload new files to your Drive. It’s not instantaneous, but it’s pretty close and doesn’t require coding skills.
Another option is to use Google Drive’s ‘Add by URL’ feature. In your Drive, click ‘New’ > ‘More’ > ‘Google Forms’ > ‘Blank Form’. In the form, add a question for the file URL. When you submit the form with a URL, it’ll add the file to your Drive. It’s a bit roundabout, but it works for occasional use.
These methods aren’t perfect, but they’re simpler than diving into API integration. Hope this helps!
hey there! i’ve actually done this before. you can use the google drive API, but it’s not as simple as a single URL. you’ll need to set up oauth2 and use the files.create endpoint. it’s a bit technical tho. maybe check out some third-party tools that make it easier? good luck!
While there’s no direct URL method to upload files to Google Drive from a web link, you can use Google Colab as a workaround. It’s a free tool that allows you to run Python code in your browser. Here’s a simple script you can use:
import requests
from google.colab import drive
drive.mount('/content/drive')
url = 'mysite.com/document.pdf'
r = requests.get(url, allow_redirects=True)
open('/content/drive/My Drive/document.pdf', 'wb').write(r.content)
This script downloads the file from the URL and saves it directly to your Google Drive. It’s not as straightforward as a single URL, but it’s relatively simple and doesn’t require extensive API knowledge. Just replace the URL with your file’s location, and you’re good to go.