-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgdrive.py
More file actions
30 lines (19 loc) · 679 Bytes
/
gdrive.py
File metadata and controls
30 lines (19 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
import os
class upGdrive:
def __init__(self, drive):
self.drive = drive
@staticmethod
def autenticator():
g_login = GoogleAuth()
g_login.LocalWebserverAuth()
drive = GoogleDrive(g_login)
return(drive)
@staticmethod
def upload(arquivo, drive):
with open(arquivo, "r") as file:
file_drive = drive.CreateFile({'title':os.path.basename(file.name)})
file_drive.SetContentString(file.read())
file_drive.Upload()
#file_drive.GetContentFile('teste_download.txt', mimetype=None)