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)
사용하는 대신 '삽입'답장을 보내 – hizbul25