2017-10-01 9 views
0

Google 드라이브에 txt 파일을 업로드하는 데 문제가 있습니다. 코드를 실행하면 모든 것이 원활 해지지만 Google 드라이브로 이동해도 아무 것도 업로드되지 않았습니다. 이견있는 사람?Google 드라이브 Python 3에 txt 파일 업로드

json_key = json.load(open('jsonkey.json') 
scope = ['https://www.googleapis.com/auth/drive'] 
credentials = ServiceAccountCredentials.from_json_keyfile_name('/home/pi/Downloads/jsonkey.json',scope) 

http = httplib2.Http() 
http = credentials.authorize(http) 

drive_service = build('drive', 'v2', http=http) 

media_body1 = MediaFileUpload('sensor1Text.txt', mimetype='text/plain', resumable=True) 
body1 = {'title': 'Sensor1','description': 'A test document', 
     'mimeType': 'text/plain'} 

sensor1File = drive_service.files().insert(body=body1, media_body=media_body1).execute() 
pprint.pprint(sensor1File) 

media_body2 = MediaFileUpload('sensor2Text.txt', mimetype='text/plain', resumable=True) 
body2 = {'title': 'Sensor2','description': 'A test document', 
     'mimeType': 'text/plain'} 

sensor2File = drive_service.files().insert(body=body2, media_body=media_body2).execute() 
pprint.pprint(sensor2File) 

media_bodyCV = MediaFileUpload('cumulativeViewText.txt', mimetype='text/plain', resumable=True) 
bodyCV = {'title': 'CumulativeView','description': 'A test document', 
     'mimeType': 'text/plain'} 

CVFile = drive_service.files().insert(body=bodyCV, media_body=media_bodyCV).execute() 
pprint.pprint(CVFile) 
+0

사용하는 대신 '삽입'답장을 보내 – hizbul25

답변

0

사용 create 대신에 [모든] insert.

예 :

CVFile = drive_service.files().create(body=bodyCV, media_body=media_bodyCV, fields='id').execute() 
+0

감사의 '생성'. 생성하려고 할 때 : 'AttributeError : 'Resource'객체에 'create'속성이 없습니다. –

+0

'v3'으로 변경되었으며 원활하게 디버깅되었지만 여전히 Google 드라이브에는 아무 것도 없습니다. –