googlearchive / PyDrive

Google Drive API Python wrapper library
Other
1.31k stars 272 forks source link

How to send desktop files to drive? #207

Open Jainu-s opened 4 years ago

Jainu-s commented 4 years ago

I have few csv files and I want to send to google drive how to send it and also if I want to automate this process from web so how to use yaml file.

veyselolgun commented 4 years ago

Hello, first of all you need to get client_secrets.json file from google. You can search how to get .json file When i tried this code it worked you can try it. When you run this code, it will ask you verification code via command line, what you have to do is that go to the link from your browser and get the code and then paste it to command line. If no error your file will be uploaded to google drive. (Be carefull for security problem, because google say that "Unverified Apps" for Quickstart App) (If you dont want to use command line, then you need to change CommandLineAuth() to LocalWebserverAuth())

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

gauth = GoogleAuth()
gauth.CommandLineAuth()

drive = GoogleDrive(gauth)
file  = drive.CreateFile()
file.SetContentFile("out000.mp3")
file.Upload()