Skip to main content

free_storage

Motivation

GoogleDrive provides up to 15GB of free storage (as of the date of writing). The offical Python API (pydrive) is a bit tricky to use when you have a nested directory structure. The goal here is to be able to manipulate files GoogleDrive as if you are on your local drive using os. If you are using GoogleCloud, S3 or other paid storage services, cloud-storage-client will be a better library. As the name suggests, this is only useful if you want to stick to the free stuff :)

Installation

pip install free_storage

To use the library for the first time, you need to follow this tutorial to generate gdrive_credentials.json. Also you need to define an extra gdrive_settings.yaml file.

# gdrive_credentials.json
{"access_token": XXXX, "client_id": XXXX, "client_secret": XXXX, ...}
# gdrive_settings.yaml
client_config_backend: settings
client_config:
  client_id: XXXX
  client_secret: XXXX

save_credentials: True
save_credentials_backend: file
save_credentials_file: gdrive_credentials.json

get_refresh_token: True

oauth_scope:
  - https://www.googleapis.com/auth/drive
  - https://www.googleapis.com/auth/drive.metadata

Below is an example of how the interface is used

from free_storage import GoogleDriveStorage

drive = GoogleDriveStorage(
    setting_file_name="path/to/gdrive_settings.yaml",
    credential_file_name="path/to/gdrive_credentials.json"
)

# Create a folder under root
drive.create_file("directory_name")

# Upload an existing file locally to a remote path
drive.create_file(
    remote_path="directory_name/test.zip",
    local_path="test.zip",
)

# Upload content in memory to a file in remote path
drive.create_file(
    remote_path="directory_name/test.txt",
    content="some string",
)

# Download file
drive.download_file(
    remote_path="directory_name/test.txt",
    local_path="test.txt"
)

# Delete file
drive.delete_file("directory_name/test.txt")

TODO

  • For create_file method under GoogleDriveStorage, allow creating nested levels of directories, instead of just one level down
  • Stream reading large files without downloading the whole file to local

Metadata

Release files for free-storage 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for free-storage 0.1.0
File Size Uploaded Provenance
free_storage-0.1.0.tar.gz 8.0 kB Without provenance Details

Release files / free_storage-0.1.0.tar.gz

Download URL free_storage-0.1.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9c1d5489d6c3d813f2a23daa07feed98ff473857ece6365a89e2ae15e76a1872
BLAKE2b-256 checksum
How to use checksums
220896cf1bf65809b2f4caaa0dafe0422fefd8bb648daa9997773d3f968f7e56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4

Security for free-storage 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page