Ist jemand mit der Google Drive-API vertraut, um mir mitzuteilen, was ich unten mit meinem Code falsch mache? Ich versuche gerade, eine Datei über die API und ein Dienstkonto auf mein Google-Laufwerk zu übertragen. Wenn ich es laufen, ich eine Datei-ID zu bekommen, aber die Datei doesnt zeigt tatsächlich in meinem Laufwerk, so dass ich habe keine Ahnung, wo die Datei tatsächlich gehen wird ...Python mit Google Drive-API
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
from apiclient.http import MediaFileUpload
#Set up a credentials object I think
creds = ServiceAccountCredentials.from_json_keyfile_name('service_account.json', ['https://www.googleapis.com/auth/drive'])
#Now build our api object, thing
drive_api = build('drive', 'v3', credentials=creds)
file_name = "test.html"
print "Uploading file " + file_name + "..."
#We have to make a request hash to tell the google API what we're giving it
body = {'name': file_name, 'mimeType': 'application/vnd.google-apps.document'}
#Now create the media file upload object and tell it what file to upload,
#in this case 'test.html'
media = MediaFileUpload('test.html', mimetype = 'text/html')
#Now we're doing the actual post, creating a new file of the uploaded type
fiahl = drive_api.files().create(body=body, media_body=media).execute()
#Because verbosity is nice
print "Created file '%s' id '%s'." % (fiahl.get('name'), fiahl.get('id')