{ "info": { "author": "Zachary Voase", "author_email": "z@zacharyvoase.com", "bugtrack_url": null, "classifiers": [], "description": "# `django-castor`\n\n`django-castor` is a re-usable app for Django which provides a\n**content-addressable storage backend**. The main class,\n`djcastor.storage.CAStorage`, is a type of `FileSystemStorage` which saves files\nunder their SHA-1 digest.\n\n* No matter how many times the same file is uploaded, it will only ever be\n stored once, thus eliminating redundancy.\n\n* Filenames are pseudorandom and made up only of hexadecimal characters, so\n you don\u2019t have to worry about filename collisions or sanitization.\n\n* `django-castor` shards files in the uploads directory based on their\n digests; this prevents filesystem issues when too many files are in a single\n directory.\n\nFor more information on the CAS concept, see the [wikipedia page][].\n\n [wikipedia page]: http://en.wikipedia.org/wiki/Content-addressable_storage\n\n\n## Installation\n\n pip install django-castor # or\n easy_install django-castor\n\n\n## Usage\n\nBasic usage is as follows:\n\n from django.db import models\n from djcastor import CAStorage\n\n class MyModel(models.Model):\n ...\n uploaded_file = models.FileField(storage=CAStorage(),\n upload_to='uploads')\n\nAt the moment, Django requires a non-empty value for the `upload_to` parameter.\nNote that `CAStorage` will **not** use this value; if you need to customize the\ndestination for uploaded files, use the `location` parameter (see below).\n\nFor extended usage, there are several options you can pass to the `CAStorage`\nconstructor. The first two are inherited from the built-in `FileSystemStorage`:\n\n* `location`: The absolute path to the directory that will hold uploaded\n files. If omitted, this will be set to the value of the `MEDIA_ROOT`\n setting.\n\n* `base_url`: The URL that serves the files stored at this location. If\n omitted, this will be set to the value of the `MEDIA_URL` setting.\n\n`CAStorage` also adds two custom options:\n\n* `keep_extension` (default `True`): Preserve the extension on uploaded files.\n This allows the webserver to guess their `Content-Type`.\n\n* `sharding` (default `(2, 2)`): The width and depth to use when sharding\n digests, expressed as a two-tuple. The following examples show how these\n parameters affect the sharding:\n\n >>> digest = '1f09d30c707d53f3d16c530dd73d70a6ce7596a9'\n\n >>> print shard(digest, width=2, depth=2)\n 1f/09/1f09d30c707d53f3d16c530dd73d70a6ce7596a9\n\n >>> print shard(digest, width=2, depth=3)\n 1f/09/d3/1f09d30c707d53f3d16c530dd73d70a6ce7596a9\n\n >>> print shard(digest, width=3, depth=2)\n 1f0/9d3/1f09d30c707d53f3d16c530dd73d70a6ce7596a9\n\n\n## Caveats\n\nThe first small caveat is that content-addressable storage is not suited to\nrapidly-changing content. If your website modifies the contents of file fields\non a regular basis, it might be a better idea to use a UUID-based storage\nbackend for those fields.\n\nThe second, more important caveat with this approach is that if the parent model\nof a file is deleted, the file will remain on disk. Because individual files may\nbe referred to by more than one model, and `django-castor` has no awareness of\nthese references, it leaves file deletion up to the developer.\n\nFor the most part, you can get away without deleting uploads. In fact,\ncontent-addressable storage is often used for long-term archival systems, where\nfiles are immutable and must be kept for future auditing (usually for compliance\nwith government regulations).\n\nIf disk space is at a premium and you need to delete uploads, there are two\napproaches you might want to take:\n\n* Garbage collection: write a script that walks through the list of uploaded\n files and checks references to each one. If no references are found, delete\n the file.\n\n* Reference counting: denormalize the `FileField` into a separate model, and\n keep a count of all the models pointing to it. Once this count reaches zero,\n delete the file from the filesystem.\n\n\n## (Un)license\n\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or distribute this\nsoftware, either in source code form or as a compiled binary, for any purpose,\ncommercial or non-commercial, and by any means.\n\nIn jurisdictions that recognize copyright laws, the author or authors of this\nsoftware dedicate any and all copyright interest in the software to the public\ndomain. We make this dedication for the benefit of the public at large and to\nthe detriment of our heirs and successors. We intend this dedication to be an\novert act of relinquishment in perpetuity of all present and future rights to\nthis software under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\nCONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to \n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/zacharyvoase/django-castor", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-castor", "package_url": "https://pypi.org/project/django-castor/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-castor/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/zacharyvoase/django-castor" }, "release_url": "https://pypi.org/project/django-castor/0.2.1/", "requires_dist": null, "requires_python": null, "summary": "A content-addressable storage backend for Django.", "version": "0.2.1" }, "last_serial": 1046753, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "08a6ef386cda5c3e4ef22b47272edb5f", "sha256": "a4072b783c5062758d6b9a1b3fe077093a9375670b568265fd0351e0b8400ea1" }, "downloads": -1, "filename": "django-castor-0.1.tar.gz", "has_sig": false, "md5_digest": "08a6ef386cda5c3e4ef22b47272edb5f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7838, "upload_time": "2010-04-09T19:25:02", "url": "https://files.pythonhosted.org/packages/77/ea/61d7af278a5c08112d89629c5f11fda58a4fd7e13ddf20e8555e5e384948/django-castor-0.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "676abb81eaad8989b2036133647a9ffb", "sha256": "579c7b54b5a1bab496f1d555374c2560f41c70efee44a72a98946c55265e9f98" }, "downloads": -1, "filename": "django-castor-0.2.0.tar.gz", "has_sig": false, "md5_digest": "676abb81eaad8989b2036133647a9ffb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5467, "upload_time": "2014-03-04T19:07:03", "url": "https://files.pythonhosted.org/packages/f3/5b/25ef664ae8da74cf156e9aaf6a1dbf4e8970d9e4ef4dbfc5d07915b2f668/django-castor-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "ea379f344380f1826da7bdc5b64c5d25", "sha256": "0c030584359b4707b713f12492a5f5b0c8c7aa8a6b61913d9196265d21a2fe79" }, "downloads": -1, "filename": "django-castor-0.2.1.tar.gz", "has_sig": false, "md5_digest": "ea379f344380f1826da7bdc5b64c5d25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5471, "upload_time": "2014-03-31T14:09:56", "url": "https://files.pythonhosted.org/packages/d0/28/913fdb2d07ef7a4e6e0eeabae8b84cd69a8fcf21b28e37004f0a69e2c128/django-castor-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ea379f344380f1826da7bdc5b64c5d25", "sha256": "0c030584359b4707b713f12492a5f5b0c8c7aa8a6b61913d9196265d21a2fe79" }, "downloads": -1, "filename": "django-castor-0.2.1.tar.gz", "has_sig": false, "md5_digest": "ea379f344380f1826da7bdc5b64c5d25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5471, "upload_time": "2014-03-31T14:09:56", "url": "https://files.pythonhosted.org/packages/d0/28/913fdb2d07ef7a4e6e0eeabae8b84cd69a8fcf21b28e37004f0a69e2c128/django-castor-0.2.1.tar.gz" } ] }