ltdconveyor/s3/upload.py
def create_dir_redirect_object(bucket_dir_path, bucket, metadata=None,
                               acl=None, cache_control=None):
    """Create an S3 object representing a directory that's designed to
    redirect a browser (via Fastly) to the ``index.html`` contained inside
    that directory.

    Parameters
    ----------
    bucket_dir_path : `str`
        Full name of the object in the S3, which is equivalent to a POSIX
        directory path, like ``dir1/dir2``.
    bucket : boto3 Bucket instance
        S3 bucket.
    metadata : `dict`, optional
        Header metadata values. These keys will appear in headers as
        ``x-amz-meta-*``.
    acl : `str`, optional
        A pre-canned access control list. See
        https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
        Default is None, meaning that no ACL is applied to the object.
    cache_control : `str`, optional
        The cache-control header value. For example, ``'max-age=31536000'``.
    """
    # Just the name of the 'directory' itself
    bucket_dir_path = bucket_dir_path.rstrip('/')

    # create a copy of metadata
    if metadata is not None:
        metadata = dict(metadata)
    else:
        metadata = {}

    # header used by LTD's Fastly Varnish config to create a 301 redirect
    metadata['dir-redirect'] = 'true'

    upload_object(bucket_dir_path,
                  content='',
                  bucket=bucket,
                  metadata=metadata,
                  acl=acl,
                  cache_control=cache_control)
def create_dir_redirect_object(bucket_dir_path, bucket, metadata=None,
                               acl=None, cache_control=None):
    """Create an S3 object representing a directory that's designed to
    redirect a browser (via Fastly) to the ``index.html`` contained inside
    that directory.

    Parameters
    ----------
    bucket_dir_path : `str`
        Full name of the object in the S3, which is equivalent to a POSIX
        directory path, like ``dir1/dir2``.
    bucket : boto3 Bucket instance
        S3 bucket.
    metadata : `dict`, optional
        Header metadata values. These keys will appear in headers as
        ``x-amz-meta-*``.
    acl : `str`, optional
        A pre-canned access control list. See
        https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
        Default is None, meaning that no ACL is applied to the object.
    cache_control : `str`, optional
        The cache-control header value. For example, ``'max-age=31536000'``.
    """
    # Just the name of the 'directory' itself
    bucket_dir_path = bucket_dir_path.rstrip('/')

    # create a copy of metadata
    if metadata is not None:
        metadata = dict(metadata)
    else:
        metadata = {}

    # header used by LTD's Fastly Varnish config to create a 301 redirect
    metadata['dir-redirect'] = 'true'

    upload_object(bucket_dir_path,
                  content='',
                  bucket=bucket,
                  metadata=metadata,
                  acl=acl,
                  cache_control=cache_control)
Create an S3 object representing a directory that's designed to
    redirect a browser (via Fastly) to the ``index.html`` contained inside
    that directory.

    Parameters
    ----------
    bucket_dir_path : `str`
        Full name of the object in the S3, which is equivalent to a POSIX
        directory path, like ``dir1/dir2``.
    bucket : boto3 Bucket instance
        S3 bucket.
    metadata : `dict`, optional
        Header metadata values. These keys will appear in headers as
        ``x-amz-meta-*``.
    acl : `str`, optional
        A pre-canned access control list. See
        https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
        Default is None, meaning that no ACL is applied to the object.
    cache_control : `str`, optional
        The cache-control header value. For example, ``'max-age=31536000'``.