FastCloud
Up & Download files to any cloud storage.
Simplistic unified interface for uploading and downloading files to the cloud.
Supports
- Azure Blob Storage :white_check_mark:
- S3 Storages (Amazon, ...) :question:
Installation
Install via pypi with:
pip install fastcloud[full]
pip install fastcloud[azure]
pip install fastcloud[s3]
Or check-out the repository and work from there.
Usage
Init storage (Azure blob, S3 ...)
To directly up and download files to the cloud storage provider, you can use the following code snippets.
from fastcloud import AzureBlobStorage, S3Storage, create_cloud_storage
cloud_store = AzureBlobStorage(connection_string="DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=...")
cloud_store = S3Storage(access_key_id, secret_access_key, region_name)
cloud_store = create_cloud_storage(... your credentials ...)
Recommendation: Use environment variables to store the cloud storage access tokens / credentials.
Upload and download files
Option 1: Just with plain bytes io
file_url = cloud_store.upload(file="path/to/file", file_name="my_file", folder="my_upload_dir")
cloud_store.download(file_id, save_path="path/to/save")
Option 2: with media-toolkit. Media-toolkit provides easy to use classes for images, videos, audio files.
from media_toolkit import ImageFile
my_img = ImageFile.from_np_array(my_cv2_img)
file_url = cloud_store.upload(file=my_img)
media_file = cloud_store.download(file_url)
Tutorials
How to setup Azure Blob Storage and get connection string?
- Go to portal.azure.com and login.
- Create a storage account of your choice (choose Blob Storage option)
- Navigate to storage account, click on containers and add container
- Go back to your storage account. Click on Access keys and copy the connection string.
- Add the connection string to your environment variables.
Contribute
Test and implement S3 features.
Missing a cloud provider?
- Just implement the missing class in core/providers with inheritance of the interface i_cloud_storage and make a pull request
Missing a feature?
- Feel free to raise an issue. Better tough: just implement it and make a PR.
Also have a look at media-toolkit, FastTaskAPI for your personal cloud solution.
SUPPORT SOCAITY BY LEAVING A STAR