dniop.blogg.se

Python google drive upload
Python google drive upload






python google drive upload

New_entry = uploader.UploadFile(uri, entry=(title=(text=os.path.basename(fhandle.name)))) Uploader = (docsclient, fhandle, file_type, file_size, chunk_size=1048576, desired_class=) #resources = docsclient.GetAllResources(uri='' + collection + '&title-exact=true') # Make sure Google doesn't try to do any conversion on the upload (e.g. Uri = resources.get_resumable_create_media_link().href Sys.exit('Error: The collection "' + collection + '" was not found.') Sys.exit('ERROR: Unable to retrieve resources') Resources = docsclient.GetAllResources(uri='' + collection + '&title-exact=true')

python google drive upload

Sys.exit('Login Error, perhaps incorrect username/password')

python google drive upload

# Get a list of all available resources (GetAllResources() requires >= gdata-2.0.15)ĭocsclient.ClientLogin(username, password, docsclient.source) Įxcept (, ), e: #file_type = 'application/+xml'ĭocsclient = (source='RPi Python-GData 2.0.17') # Manually associate the file type.Magic too much of a pig Parser.add_argument('-f','-filename', help='-f -filename The file name for the KML file.',required=True)įile_size = os.path.getsize(fhandle.name) Google Drive Directory to store the KML files.',required=False) Parser.add_argument('-l','-location', default='My Tracks', help='-l -location. Parser.add_argument('-p','-password', help='-p -password. Parser.add_argument('-u','-username', help='-u -username. Parser = argparse.ArgumentParser(description='Python script that KML files and uploads them to Google Drive.') # Desired feature to grab all the kml/jpg files on the directory and dump them at once Print("Uploaded File '".format(file.get("name"), file.# Written by Peter Nichols to copy files to Google Drive. Mimetype="application/", # I'm converting docx to native google docsįile = drive_service.files().create(body=file_metadata, Media = MediaIoBaseUpload(io.BytesIO(file_info), # **Pass your bytes object/string here "mimeType": "application/", # Mimetype for docx The tech stack I'm using is Angular 8 for frontend & Tornado Python for backend.įrom googleapiclient.discovery import buildįrom googleapiclient.http import MediaIoBaseUploadįrom gdrive_config import credentials # Import your credentials object created using a service accountĭrive_service = build("drive", "v3", credentials=credentials, cache_discovery=False)įile_info = file # Here "my_docx_file" is the key name you have set in form data Now this file, I want to upload to google drive. The following case is, I am sending a docx file from my frontend application using formdata & receiving it on the backend. For those looking for a way to upload a file not through a url, but using formdata or any media object/string which is in bytes, here is the sample code.








Python google drive upload