ltdconveyor/s3/upload.py
def upload_object(bucket_path, bucket, content='',
                  metadata=None, acl=None, cache_control=None,
                  content_type=None):
    """Upload an arbitrary object to an S3 bucket.

    Parameters
    ----------
    bucket_path : `str`
        Destination path (also known as the key name) of the file in the
        S3 bucket.
    content : `str` or `bytes`, optional
        Object content.
    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'``.
    content_type : `str`, optional
        The object's content type (such as ``text/html``). If left unset,
        no MIME type is passed to boto3 (which defaults to
        ``binary/octet-stream``).
    """
    obj = bucket.Object(bucket_path)

    # Object.put seems to be sensitive to None-type kwargs, so we filter first
    args = {}
    if metadata is not None and len(metadata) > 0:  # avoid empty Metadata
        args['Metadata'] = metadata
    if acl is not None:
        args['ACL'] = acl
    if cache_control is not None:
        args['CacheControl'] = cache_control
    if content_type is not None:
        args['ContentType'] = content_type

    obj.put(Body=content, **args)
def upload_object(bucket_path, bucket, content='',
                  metadata=None, acl=None, cache_control=None,
                  content_type=None):
    obj = bucket.Object(bucket_path)

    # Object.put seems to be sensitive to None-type kwargs, so we filter first
    args = {}
    if metadata is not None and len(metadata) > 0:  # avoid empty Metadata
        args['Metadata'] = metadata
    if acl is not None:
        args['ACL'] = acl
    if cache_control is not None:
        args['CacheControl'] = cache_control
    if content_type is not None:
        args['ContentType'] = content_type

    obj.put(Body=content, **args)
def upload_object ( bucket_path , bucket , content = '' , metadata = None , acl = None , cache_control = None , content_type = None ) : obj = bucket . Object ( bucket_path ) # Object.put seems to be sensitive to None-type kwargs, so we filter first args = { } if metadata is not None and len ( metadata ) > 0 : # avoid empty Metadata args [ 'Metadata' ] = metadata if acl is not None : args [ 'ACL' ] = acl if cache_control is not None : args [ 'CacheControl' ] = cache_control if content_type is not None : args [ 'ContentType' ] = content_type obj . put ( Body = content , * * args )
Upload an arbitrary object to an S3 bucket.

    Parameters
    ----------
    bucket_path : `str`
        Destination path (also known as the key name) of the file in the
        S3 bucket.
    content : `str` or `bytes`, optional
        Object content.
    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'``.
    content_type : `str`, optional
        The object's content type (such as ``text/html``). If left unset,
        no MIME type is passed to boto3 (which defaults to
        ``binary/octet-stream``).
Upload an arbitrary object to an S3 bucket .