Cloud storage IO for humans
Project description
cloudstorageio
Cloud storage IO for humans
Developed and tested on python 3.7+
Getting Started
These instructions will get you a copy of the project up and running on your local machine.
Prerequisites
sudo apt install python3.6
sudo apt install python3-pip
-
S3 configs
pip install awscli --upgrade --user
set your aws configs
sudo apt install awscli
$ aws configure AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY Default region name [None]: us-west-2 Default output format [None]: json
click here for more info about configuration and installation
-
Google cloud storage configs
Provide authentication credentials to your application code by setting the environment variable GOOGLE_APPLICATION_CREDENTIALS. Replace [FILE_NAME] with the file of the JSON file that contains your service account key
GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/[FILE_NAME].json"
click here for more info about configuration and installation
Installation
pip install cloudstorageio
Usage
from cloudstorageio import CloudInterface
google_file_path = 'gs://bucket-name/path-to-file/sample-file.txt'
s3_file_path = 's3://bucket-name/path-to-file/sample-pic.jpg'
local_file_path = 'path-to-file/sample-text-file.txt'
ci = CloudInterface()
# Write text to Google cloud storage file
with ci.open(google_file_path, 'w') as f:
f.write("Lorem Ipsum is simply dummy text")
# Read picture from S3 storage
with ci.open(s3_file_path, 'rb') as f:
s3_output = f.read() # binary content of picture
# Read text locally
with ci.open(local_file_path, 'r') as f:
local_output = f.read() # string content of text file
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cloudstorageio-1.0.0.tar.gz
(9.2 kB
view hashes)
Built Distribution
Close
Hashes for cloudstorageio-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15822184efc77183e17815c16faeccab5b38d661c57c56fa850fbc7587a603a4 |
|
MD5 | 020bde5204d8525bcddbe458ad2968ab |
|
BLAKE2b-256 | f2438dab602e5f573a5efabdd50a0c9ef424c3dab9d81dde033c8cab902a1ca6 |