# Path: sigal/signals.py



import logging
import os
    import boto
from click import progressbar
from sigal import signals
    from boto.s3.key import Key
    filename, ext = os.path.splitext(f)
    options = gallery.settings["upload_s3_options"]

    proposed_cache_control = None
    if "media_max_age" in options and ext in [".jpg", ".png", ".webm", ".mp4"]:
        proposed_cache_control = "max-age=%s" % options["media_max_age"]
    elif "max_age" in options:
        proposed_cache_control = "max-age=%s" % options["max_age"]
    return proposed_cache_control


def upload_file(gallery, bucket, f):
    logger.debug("Uploading file %s", f)


    key = Key(bucket)
    key.key = f

    cache_metadata = generate_cache_metadata(gallery, f)
    if cache_metadata:
        key.set_metadata("Cache-Control", cache_metadata)

    key.set_contents_from_filename(
        os.path.join(gallery.settings["destination"], f),
        policy=gallery.settings["upload_s3_options"]["policy"],
    )


def register(settings):
    if settings.get("upload_s3_options"):

# Path: sigal/signals.py



# Path: sigal/plugins/upload_s3.py
import logging
import os
    import boto
from click import progressbar
from sigal import signals
    from boto.s3.key import Key

    filename, ext = os.path.splitext(f)
    options = gallery.settings["upload_s3_options"]

    proposed_cache_control = None
    if "media_max_age" in options and ext in [".jpg", ".png", ".webm", ".mp4"]:
        proposed_cache_control = "max-age=%s" % options["media_max_age"]
    elif "max_age" in options:
        proposed_cache_control = "max-age=%s" % options["max_age"]
    return proposed_cache_control


def upload_file(gallery, bucket, f):
    logger.debug("Uploading file %s", f)


    key = Key(bucket)
    key.key = f

    cache_metadata = generate_cache_metadata(gallery, f)
    if cache_metadata:
        key.set_metadata("Cache-Control", cache_metadata)

    key.set_contents_from_filename(
        os.path.join(gallery.settings["destination"], f),
        policy=gallery.settings["upload_s3_options"]["policy"],
    )


def register(settings):
    if settings.get("upload_s3_options"):

        signals.gallery_build.connect(upload_s3)