googlearchive/PyDrive

How to send desktop files to drive?

Jainu-s opened this issue · 1 comments

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.

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()