aiostorage package¶
Subpackages¶
Submodules¶
Full documentation of each module in this package (aimed at library developers):
aiostorage.blob_storage module¶
This module contains the BlobStorage class.
-
class
aiostorage.blob_storage.
BlobStorage
(provider, **kwargs)¶ Bases:
object
Asynchronous object storage interface for common operations, e.g. uploading a file to a bucket.
Providers currently supported:
Backblaze.
-
PROVIDER_ADAPTER
= {'backblaze': {'adapter': <class 'aiostorage.providers.backblaze.Backblaze'>, 'required': ('account_id', 'app_key')}}¶
-
__init__
(provider, **kwargs)¶ Set the object storage provider.
Parameters: - provider (str) – Name of the object storage provider. Must be one of ‘backblaze’.
- **kwargs – Credentials for the object storage provider, see below.
- : Keyword arguments:
- account_id (
str
) – Account id (Backblaze). - app_key (
str
) – Application key (Backblaze).
- account_id (
-
upload_file
(bucket_id, file_to_upload)¶ async Upload a single file to the object storage provider.
Parameters: - bucket_id (str) – Object storage provider bucket to upload files to.
- file_to_upload (dict) – Local file to upload, {‘path’: str, ‘content_type’: str}.
Raises: - ProviderAuthorizationError – If authorization to the object storage provider is unsuccessful.
- ProviderFileUploadError – If uploading of the file to the object storage provider bucket is unsuccessful.
Returns: Response from object storage provider.
Return type: dict
-
aiostorage.exceptions module¶
This module contains exceptions for the BlobStorage class.
-
exception
aiostorage.exceptions.
BlobStorageError
¶ Bases:
Exception
Base exception class.
-
exception
aiostorage.exceptions.
BlobStorageMissingCredentialsError
¶ Bases:
aiostorage.exceptions.BlobStorageError
Missing credentials for object storage provider authorization.
-
exception
aiostorage.exceptions.
BlobStorageUnrecognizedProviderError
¶ Bases:
aiostorage.exceptions.BlobStorageError
Unrecognized object storage provider.
Module contents¶
Package summary and abridged documentation of exported classes (aimed at end users):
This package provides the API for public consumption.
Example usage
import asyncio
from aiostorage import BlobStorage
file1 = {'content': 'application/pdf', 'path': '/path/to/pdf'}
file2 = {'content': 'video/mp4', 'path': '/path/to/video'}
storage = BlobStorage('backblaze', app_key='key8923', account_id='234234')
coros = [storage.upload_file('bucket-1234', file1),
storage.upload_file('bucket-1234', file2)]
parent_future = asyncio.gather(*coros)
loop = asyncio.get_event_loop()
loop.run_until_complete(parent_future)
loop.close()
-
class
aiostorage.
BlobStorage
(provider, **kwargs)¶ Bases:
object
Asynchronous object storage interface for common operations, e.g. uploading a file to a bucket.
Providers currently supported:
Backblaze.
-
PROVIDER_ADAPTER
= {'backblaze': {'adapter': <class 'aiostorage.providers.backblaze.Backblaze'>, 'required': ('account_id', 'app_key')}}¶
-
__init__
(provider, **kwargs)¶ Set the object storage provider.
Parameters: - provider (str) – Name of the object storage provider. Must be one of ‘backblaze’.
- **kwargs – Credentials for the object storage provider, see below.
- : Keyword arguments:
- account_id (
str
) – Account id (Backblaze). - app_key (
str
) – Application key (Backblaze).
- account_id (
-
upload_file
(bucket_id, file_to_upload)¶ async Upload a single file to the object storage provider.
Parameters: - bucket_id (str) – Object storage provider bucket to upload files to.
- file_to_upload (dict) – Local file to upload, {‘path’: str, ‘content_type’: str}.
Raises: - ProviderAuthorizationError – If authorization to the object storage provider is unsuccessful.
- ProviderFileUploadError – If uploading of the file to the object storage provider bucket is unsuccessful.
Returns: Response from object storage provider.
Return type: dict
-
-
exception
aiostorage.
BlobStorageUnrecognizedProviderError
¶ Bases:
aiostorage.exceptions.BlobStorageError
Unrecognized object storage provider.
-
exception
aiostorage.
BlobStorageMissingCredentialsError
¶ Bases:
aiostorage.exceptions.BlobStorageError
Missing credentials for object storage provider authorization.