Skip to main content

Settings to Upload files to google drive

Project description

Project logo

Kami Google Drive

Status GitHub release issues - kami-logging pulls - kami-logging License


Simple functions to create folder and upload files using google drive api

📝 Table of Contents

🧐 About

This package arose from the need to simplify the google drive management tasks of applications created by the Kami CO software development team.

Currently the package has 6 functions: get_service, connect, get_folder_id, create_folder, upload_file, upload_files

🏁 Getting Started

These instructions will get you a copy of the package and a daily use example.

Prerequisites

  • python >= 3.9
  • kami-logging >= 0.2.0
  • google-api-core >= 2.11.0
  • google-api-python-client >= 2.50.0
  • google-auth-httplib2 >= 0.1.0
  • google-auth-oauthlib >= 0.5.2
  • google-auth >= 2.7.0
  • googleapis-common-protos >= 1.56.2

Installing

$pip install kami-gdrive

🎈 Usage

To get work with this package first you need to create an project and an agent and get json file with correspondent credentials jus the way of google drive api documentation find here

The 6 functions available are:

  • get_service():

Get a service that communicates to a Google API.

Args:

  • api_name : The name of the api to connect to.
  • api_version : The api version to connect to.
  • scopes : A list auth scopes to authorize for the application.
  • key_file_location : The path to a valid service account JSON key file.

Returns: A service that is connected to the specified API.

  • connect(service_account_credentials):

Connect with google drive api service.

Args:

  • service_account_credentials : The path to a valid service account JSON key file.

Returns: A google drive api service.

  • get_folder_id(parent_folder_id, folder_name):

Get id of a folder in driver if its exists.

Args:

  • parent_folder_id : Id to root or parent folder when search will begin.
  • folder_name : Searched folder name

Returns: Id to folder or None

  • create_folder(parent_folder_id, folder_name):

  • Create New Folder in especified parent folder.

Args:

  • parent_folder_id : Id to root or parent folder when new folder will be created.
  • folder_name : Name for the new folder

Returns: Id to new folder or None

  • upload_file(folder_id, this_file):

  • Upload an local file to especified folder on google drive.

Args:

  • folder_id : Id to the folder when this file will be uploaded.
  • this_file : Absolute or Relative full path to the local file.

Returns: Show an log with the result of process

  • upload_files(folder_id, files_list):

  • Upload an list of local file to especified folder on google drive.

Args:

  • folder_id : Id to the folder when this file will be uploaded.
  • files_list : List of Absolute or Relative full path to the each local file.

Returns: Show an log with the result of process

example:

from kami_gdrive import create_folder, get_folder_id, upload_file
root_folder_id = '1eAnlW53WAOJn-eaLdM2AqRYnl0ui9qrL'
my_new_folder_id = create_folder(root_folder_id, 'my_new_folder')
local_file = 'Path/To/My/file.ext'
upload_file(my_new_folder_id, local_file)

Result:

Project logo

⛏️ Built Using

✍️ Authors

See also the list of contributors who participated in this project.

🎉 Acknowledgements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kami_gdrive-0.1.3.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

kami_gdrive-0.1.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file kami_gdrive-0.1.3.tar.gz.

File metadata

  • Download URL: kami_gdrive-0.1.3.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.9.2 Linux/5.10.0-18-amd64

File hashes

Hashes for kami_gdrive-0.1.3.tar.gz
Algorithm Hash digest
SHA256 122c2ef9eab7c3ed0fb1a6893d2d7a6cd0da96adfd6dcf29f13385c2b19f6f9d
MD5 2ba0baf083e737380b051f106d75c2de
BLAKE2b-256 e62abb6ad94a5fdad96f6a7f1a969227228c93089c3e77335dc2b8736d795748

See more details on using hashes here.

File details

Details for the file kami_gdrive-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: kami_gdrive-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.9.2 Linux/5.10.0-18-amd64

File hashes

Hashes for kami_gdrive-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 30280197d04123483758c095c9b7a422c484c035dab53625ffc1257938d6bcab
MD5 4f084d53c12661be73899b5e91de0576
BLAKE2b-256 f0571daf4274a8cc3d1b2edadab1e0277e189c0ce97a793421b707a1e399800f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page