Ejemplo n.º 1
0
from django.utils.six.moves.urllib import parse as urlparse
from django.utils.timezone import is_naive, localtime

from storages.utils import safe_join, setting

try:
    import boto3.session
    from boto3 import __version__ as boto3_version
    from botocore.client import Config
    from botocore.exceptions import ClientError
except ImportError:
    raise ImproperlyConfigured("Could not load Boto3's S3 bindings.\n"
                               "See https://github.com/boto/boto3")


boto3_version_info = tuple([int(i) for i in boto3_version.split('.')])

if boto3_version_info[:2] < (1, 2):
    raise ImproperlyConfigured("The installed Boto3 library must be 1.2.0 or "
                               "higher.\nSee https://github.com/boto/boto3")


@deconstructible
class S3Boto3StorageFile(File):

    """
    The default file object used by the S3Boto3Storage backend.

    This file implements file streaming using boto's multipart
    uploading functionality. The file can be opened in read or
    write mode.
Ejemplo n.º 2
0
from django.utils.six.moves.urllib import parse as urlparse
from django.utils.six import BytesIO
from django.utils.timezone import localtime, is_naive

try:
    import boto3.session
    from boto3 import __version__ as boto3_version
    from botocore.client import Config
    from botocore.exceptions import ClientError
except ImportError:
    raise ImproperlyConfigured("Could not load Boto3's S3 bindings.\n"
                               "See https://github.com/boto/boto3")

from storages.utils import setting

boto3_version_info = tuple([int(i) for i in boto3_version.split('.')])

if boto3_version_info[:2] < (1, 2):
    raise ImproperlyConfigured("The installed Boto3 library must be 1.2.0 or "
                               "higher.\nSee https://github.com/boto/boto3")


def safe_join(base, *paths):
    """
    A version of django.utils._os.safe_join for S3 paths.

    Joins one or more path components to the base path component
    intelligently. Returns a normalized version of the final path.

    The final path must be located inside of the base path component
    (otherwise a ValueError is raised).
Ejemplo n.º 3
0
from django.utils.six import BytesIO
from django.utils.timezone import localtime

try:
    from boto3 import resource
    from boto3 import __version__ as boto3_version
    from botocore.client import Config
    from botocore.exceptions import ClientError
except ImportError:
    raise ImproperlyConfigured("Could not load Boto3's S3 bindings.\n"
                               "See https://github.com/boto/boto3")

from storages.utils import setting

boto3_version_info = tuple(
    [int(i) for i in boto3_version.split('-')[0].split('.')])

if boto3_version_info[:2] < (1, 2):
    raise ImproperlyConfigured("The installed Boto3 library must be 1.2.0 or "
                               "higher.\nSee https://github.com/boto/boto3")


def safe_join(base, *paths):
    """
    A version of django.utils._os.safe_join for S3 paths.

    Joins one or more path components to the base path component
    intelligently. Returns a normalized version of the final path.

    The final path must be located inside of the base path component
    (otherwise a ValueError is raised).