{ "info": { "author": "Cariad Eccleston", "author_email": "cariad@cariad.me", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Internet :: WWW/HTTP :: Site Management" ], "description": "# s3headerize\n\nA Python package for setting HTTP headers on Amazon Web Services (AWS) S3 objects.\n\nHeader values are configured per-name extension, with an optional catch-all if the object does not match any rules.\n\n## Prerequisites\n\nPython 3.x is required.\n\n## Limitations\n\nOnly `Cache-Control` and `Content-Type` headers are currently supported.\n\n## Configuring the headers and their values\n\nThe headers to set are configured in a YAML file with a list of rules.\n\nFor example:\n\n```yaml\n- header: Cache-Control\n when:\n - extension: .html\n then: max-age=300, public\n - extension: .css\n then: max-age=604800, public\n else: max-age=31536000, public\n```\n\nThe result of this will be:\n\n- Every `.html` object will receive a `Cache-Control` header with value `max-age=300, public`.\n- Every `.css` object will receive a `Cache-Control` header with value `max-age=604800, public`.\n- All other objects will receive a `Cache-Control` header with value `max-age=31536000, public`.\n\nThe `else` statement is optional. For example:\n\n```yaml\n- header: Content-Type\n when:\n - extension: .woff2\n then: font/woff2\n```\n\nThe result of this will be:\n\n- Every `.woff2` object will receive a `Content-Type` header with value `font/woff2`.\n- The `Content-Type` header (or lackthereof) on all other objects will be unchanged.\n\nThere's a sample file at [sample-header-rules.yaml](sample-header-rules.yaml).\n\n## Usage\n\n### Installation\n\n```shell\npip install s3headerize\n```\n\n### Command-line\n\n```shell\npython -m s3headerize --bucket \n --header-rules \n [--dry-run]\n [--key-prefix ]\n [--log-level ]\n```\n\nFor example:\n\n```shell\npython -m s3headerize --header-rules ./headers-rules.yaml --bucket my-website\n```\n\n### In code\n\nTo run against a bucket:\n\n```python\nfrom s3headerize import BucketHeaderizer\n\nrules = [\n {\n 'header': 'Cache-Control',\n 'when': [\n {\n 'extension': '.html',\n 'then': 'max-age=300, public'\n }\n ],\n 'else': 'max-age=31536000, public'\n },\n {\n 'header': 'Content-Type',\n 'when': [\n {\n 'extension': '.woff2',\n 'then': 'font/woff2'\n }\n ]\n }\n]\n\nbucket_headerizer = BucketHeaderizer(header_rules=rules)\nbucket_headerizer.update(bucket='my-website')\n```\n\nTo run against specific keys:\n\n```python\nfrom s3headerize import ObjectHeaderizer\n\nrules = [\n {\n 'header': 'Cache-Control',\n 'when': [\n {\n 'extension': '.html',\n 'then': 'max-age=300, public'\n }\n ],\n 'else': 'max-age=31536000, public'\n },\n {\n 'header': 'Content-Type',\n 'when': [\n {\n 'extension': '.woff2',\n 'then': 'font/woff2'\n }\n ]\n }\n]\n\nobject_headerizer = ObjectHeaderizer(bucket='my-website',\n header_rules=rules,\n key='index.html')\nobject_headerizer.update()\n```\n\n## Development\n\n### Installing dependencies\n\n```shell\npip install -e .[dev]\n```\n\n### Running tests\n\n```shell\npython test.py\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/cariad/py-s3headerize", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "s3headerize", "package_url": "https://pypi.org/project/s3headerize/", "platform": "", "project_url": "https://pypi.org/project/s3headerize/", "project_urls": { "Homepage": "https://github.com/cariad/py-s3headerize" }, "release_url": "https://pypi.org/project/s3headerize/1.0/", "requires_dist": [ "boto3", "pyyaml", "autopep8 ; extra == 'dev'", "coverage ; extra == 'dev'", "mock ; extra == 'dev'", "pylint ; extra == 'dev'" ], "requires_python": "", "summary": "A Python package for setting HTTP headers on Amazon Web Services (AWS) S3 objects.", "version": "1.0" }, "last_serial": 4775213, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "3d922f2f8776da338d0b44ed9ea3e513", "sha256": "3c7e562e14919fd091b1d6d393b2bc8860061362852d6341757b3ed8ef10294d" }, "downloads": -1, "filename": "s3headerize-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3d922f2f8776da338d0b44ed9ea3e513", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8368, "upload_time": "2019-02-03T17:17:07", "url": "https://files.pythonhosted.org/packages/cc/46/21fb690bfa9b91548e314b423bc138eae0eb67c836fcd0ee33fb800d2df1/s3headerize-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e5ff1fd8b82ab821ff95e62b93f751e0", "sha256": "a8f000c2663d9052456d8d1d9ecd2e5fba0624e2a718f04c8ccf1582b4f09cef" }, "downloads": -1, "filename": "s3headerize-1.0.tar.gz", "has_sig": false, "md5_digest": "e5ff1fd8b82ab821ff95e62b93f751e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6396, "upload_time": "2019-02-03T17:17:09", "url": "https://files.pythonhosted.org/packages/60/a4/f9d3d0a4fc1ebe8916f5e89e93f177570a61fd3e2f47c7fd59351f2032b0/s3headerize-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3d922f2f8776da338d0b44ed9ea3e513", "sha256": "3c7e562e14919fd091b1d6d393b2bc8860061362852d6341757b3ed8ef10294d" }, "downloads": -1, "filename": "s3headerize-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3d922f2f8776da338d0b44ed9ea3e513", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8368, "upload_time": "2019-02-03T17:17:07", "url": "https://files.pythonhosted.org/packages/cc/46/21fb690bfa9b91548e314b423bc138eae0eb67c836fcd0ee33fb800d2df1/s3headerize-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e5ff1fd8b82ab821ff95e62b93f751e0", "sha256": "a8f000c2663d9052456d8d1d9ecd2e5fba0624e2a718f04c8ccf1582b4f09cef" }, "downloads": -1, "filename": "s3headerize-1.0.tar.gz", "has_sig": false, "md5_digest": "e5ff1fd8b82ab821ff95e62b93f751e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6396, "upload_time": "2019-02-03T17:17:09", "url": "https://files.pythonhosted.org/packages/60/a4/f9d3d0a4fc1ebe8916f5e89e93f177570a61fd3e2f47c7fd59351f2032b0/s3headerize-1.0.tar.gz" } ] }