Started commenting CloudStorageUploader class
This commit is contained in:
parent
7018f45c0a
commit
978fc43a82
|
@ -6,6 +6,15 @@ from libcloud.storage.providers import get_driver
|
||||||
from libcloud.storage.types import Provider, ContainerDoesNotExistError, ObjectDoesNotExistError
|
from libcloud.storage.types import Provider, ContainerDoesNotExistError, ObjectDoesNotExistError
|
||||||
|
|
||||||
class CloudStorageUploader:
|
class CloudStorageUploader:
|
||||||
|
""" A class that uses Apache Libcloud's Storage API to upload objects into
|
||||||
|
various cloud storage backends.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
_provider: Storage backend. For exmaple, Amazon S3, Google Storage.
|
||||||
|
_bucket: Name of container on provider where files will get uploaded into.
|
||||||
|
_api_key: Access key to objects on the provider's storage backend.
|
||||||
|
_api_key_secret: Secret access key to objects on the provider's storage backend.
|
||||||
|
"""
|
||||||
def __init__(self, provider, bucket, api_key, api_key_secret):
|
def __init__(self, provider, bucket, api_key, api_key_secret):
|
||||||
self._provider = provider
|
self._provider = provider
|
||||||
self._bucket = bucket
|
self._bucket = bucket
|
||||||
|
@ -13,6 +22,16 @@ class CloudStorageUploader:
|
||||||
self._api_key_secret = api_key_secret
|
self._api_key_secret = api_key_secret
|
||||||
|
|
||||||
def upload_obj(self, audio_file_path, metadata):
|
def upload_obj(self, audio_file_path, metadata):
|
||||||
|
'''Uploads a file into a provider's cloud object storage.
|
||||||
|
|
||||||
|
Generates a unique object name
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
audio_file_path: Path on disk to the audio file that is about to be
|
||||||
|
uploaded to cloud object storage.
|
||||||
|
metadata: ID3 tags and other metadata extracted from the audio file.
|
||||||
|
'''
|
||||||
|
|
||||||
file_base_name = os.path.basename(audio_file_path)
|
file_base_name = os.path.basename(audio_file_path)
|
||||||
file_name, extension = os.path.splitext(file_base_name)
|
file_name, extension = os.path.splitext(file_base_name)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue