filedepot


Namefiledepot JSON
Version 0.11.0 PyPI version JSON
download
home_pagehttps://github.com/amol-/depot
SummaryToolkit for storing files and attachments in web applications
upload_time2024-02-22 21:48:13
maintainer
docs_urlNone
authorAlessandro Molina
requires_python
licenseMIT
keywords storage files s3 gridfs mongodb aws sqlalchemy wsgi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
.. image:: https://raw.github.com/amol-/depot/master/docs/_static/logo.png

DEPOT - File Storage Made Easy
==============================

.. image:: https://github.com/amol-/depot/actions/workflows/run-tests.yml/badge.svg
    :target: https://github.com/amol-/depot/actions/workflows/run-tests.yml

.. image:: https://coveralls.io/repos/amol-/depot/badge.png?branch=master
    :target: https://coveralls.io/r/amol-/depot?branch=master 

.. image:: https://img.shields.io/pypi/v/filedepot.svg
   :target: https://pypi.python.org/pypi/filedepot

DEPOT is a framework for easily storing and serving files in
web applications on Python2.6+ and Python3.2+.

DEPOT supports storing files in multiple backends, like:

* Local Disk
* In Memory (for tests)
* On GridFS
* On Amazon S3 (or compatible services)
* On Google Cloud Storage

and integrates with database by providing files
attached to your **SQLAlchemy** or **Ming/MongoDB** models
with respect to transactions behaviours (files are rolled back too).

Installing
----------

Installing DEPOT can be done from PyPi itself by installing the ``filedepot`` distribution::

    $ pip install filedepot

Getting Started
---------------

To start using Depot refer to `Documentation <https://depot.readthedocs.io/en/latest/>`_

DEPOT was `presented at PyConUK and PyConFR <http://www.slideshare.net/__amol__/pyconfr-2014-depot-story-of-a-filewrite-gone-wrong>`_ in 2014

standalone
~~~~~~~~~~

Here is a simple example of using depot standalone to store files on MongoDB::

    from depot.manager import DepotManager

    # Configure a *default* depot to store files on MongoDB GridFS
    DepotManager.configure('default', {
        'depot.backend': 'depot.io.gridfs.GridFSStorage',
        'depot.mongouri': 'mongodb://localhost/db'
    })

    depot = DepotManager.get()

    # Save the file and get the fileid
    fileid = depot.create(open('/tmp/file.png'))

    # Get the file back
    stored_file = depot.get(fileid)
    print stored_file.filename
    print stored_file.content_type

models
~~~~~~

Or you can use depot with SQLAlchemy to store attachments::

    from depot.fields.sqlalchemy import UploadedFileField
    from depot.fields.specialized.image import UploadedImageWithThumb


    class Document(Base):
        __tablename__ = 'document'

        uid = Column(Integer, autoincrement=True, primary_key=True)
        name = Column(Unicode(16), unique=True)
        content = Column('content_col', UploadedFileField)  # plain attached file

        # photo field will automatically generate thumbnail
        photo = Column(UploadedFileField(upload_type=UploadedImageWithThumb))


    # Store documents with attached files, the source can be a file or bytes
    doc = Document(name=u'Foo',
                content=b'TEXT CONTENT STORED AS FILE',
                photo=open('/tmp/file.png'))
    DBSession.add(doc)
    DBSession.flush()

    # DEPOT is session aware, commit/rollback to keep or delete the stored files.
    DBSession.commit()

ChangeLog
---------

0.11.0
~~~~~~

- Officially support Python 3.12
- Addressed deprecation of ``Image.ANTIALIAS`` in Pillow, ``Image.LANCZOS`` is used instead
- TurboGears2 is no longer needed to run tests
- Depot is now compatible with ``multipart`` module or other replacements of ``cgi.FieldStorage``
- Fixed an open file leak in ``UploadedImageWithThumb``
- Fixed an open file leak in ``WithThumbnailFilter``

0.10.0
~~~~~~

- Added support for Google Cloud Storage
- Fixed ACL issues with S3
- Deprecated boto2 backend, use boto3
- Added support for performing backups by copying to another storage

0.9.0
~~~~~

- Support for SQLAlchemy 1.4 and 2.0
- Support for SQLAlchemy objects deleted with ``.delete(synchronize_session="fetch")``
- Tests migrated to ``unittest``

0.8.0
~~~~~

- Replaced ``unidecode`` dependency with ``anyascii`` to better cope with MIT License.

0.7.1
~~~~~

- Fix a bug in AWS-S3 support for unicode filenames.

0.7.0
~~~~~

- Support for ``storage_class`` option in ``depot.io.boto3.S3Storage`` backend. Detaults to ``STANDARD``

0.6.0
~~~~~

- Officially support Python 3.7
- Fix DEPOT wrongly serving requests for any url that starts with the mountpoint. (IE: ``/depotsomething`` was wrongly served for ``/depot`` mountpoint)
- In SQLAlchemy properly handle deletion of objects deleted through ``Relationship.remove`` (IE: ``parent.children.remove(X)``)
- In SQLAlchemy properly handle entities deleted through ``cascade='delete-orphan'``

0.5.2
~~~~~

- Fixed an *start_response called a second time without providing exc_info* error with storages supporting plublic urls


0.5.1
~~~~~

- URLs generated by ``DepotMiddleware`` are now guaranteed to be plain ascii
- [Breaking change]: Bucket existance with S3 storages should now be more reliable when the
  bucket didn't already exist, but it requires an additional AWS policy: `s3:ListAllMyBuckets` that wasn't required on 0.5.0

0.5.0
~~~~~

- ``depot.io.boto3.S3Storage`` now provides support for accessing S3 with ``boto3``.
  The previously existing ``depot.io.awss3.S3Storage`` can still be used to store
  files on S3 using ``boto``.
- SQLAlchemy integration now handles deletion of files on rollback when session
  is not flushed. Previously flushing the session was required before a rollback too.
- It is now possible to run tests through ``tox`` and build docs through ``tox -e docs``
- DEPOT is now tested against Python 3.6

0.4.1
~~~~~

- Fixed installation error on non-UTF8 systems
- Improved support for polymorphic subtypes in SQLAlchemy

0.4.0
~~~~~

- Support for Python 3.5
- Fixed ``Content-Disposition`` header for filenames including a comma

0.3.2
~~~~~

- ``MemoryFileStorage`` now accepts any option, for easier testing configuration

0.3.1
~~~~~

* Fixed ``Content-Disposition`` header when serving from S3 directly
* Fixed size of SQLAlchemy field on Oracle (was bigger than the allowed maximum)

0.3.0
~~~~~

- ``MemoryFileStorage`` provides in memory storage for files. This is meant to provide a
  convenient way to speed up test suites and avoid fixture clean up issues.
- S3Storage can now generate public urls for private files (expire in 1 year)
- Files created from plain bytes are now named "unnamed" instead of missing a filename.

0.2.1
~~~~~

- ``S3Storage`` now supports the ``prefix`` option to store files in a subpath

0.2.0
~~~~~

- Storages now provide a ``list`` method to list files available on the store (This is not meant to be used to retrieve files uploaded by depot as it lists all the files).
- ``DepotExtension`` for Ming is now properly documented

0.1.2
~~~~~

- It is now possible to use multiple ``WithThumbnailFilter`` to generate multiple thumbnails
  with different resolutions.
- Better documentation for MongoDB ``UploadedFileProperty``

0.1.1
~~~~~

- Fixed a bug with Ming support when acessing ``UploadedFileProperty`` as a class property
- Improved support for DEPOT inside TurboGears admin when using MongoDB

0.1.0
~~~~~

- Added ``DepotManager.alias`` to configure aliases to storage.
  This allows easy migration from one storage to another by switching where the alias points.
- Now ``UploadedFileField`` permits to specify ``upload_storage`` to link a Model Column to a specific storage.
- Added ``policy`` and ``encrypt_key`` options to `S3Storage` to upload private and encrypted files.

0.0.6
~~~~~

- Added `host` option to `S3Storage` to allow using providers different from *AWS*.

0.0.5
~~~~~

- Added `FileIntent` to explicitly provide `content_type` and `filename` to uploaded content.

0.0.4
~~~~~

- Added Content-Disposition header with original filename in WSGI middleware

0.0.3
~~~~~

- Work-Around for issue with `wsgi.file_wrapper` provided by Waitress WSGI Server

0.0.2
~~~~~

- Official Support for AWS S3 on Python3

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/amol-/depot",
    "name": "filedepot",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "storage files s3 gridfs mongodb aws sqlalchemy wsgi",
    "author": "Alessandro Molina",
    "author_email": "amol@turbogears.org",
    "download_url": "https://files.pythonhosted.org/packages/19/76/0128b0d2958b81a5f9738680af5b3ef9cdd31513e833ecbd67dcb3fa09f1/filedepot-0.11.0.tar.gz",
    "platform": null,
    "description": "\n.. image:: https://raw.github.com/amol-/depot/master/docs/_static/logo.png\n\nDEPOT - File Storage Made Easy\n==============================\n\n.. image:: https://github.com/amol-/depot/actions/workflows/run-tests.yml/badge.svg\n    :target: https://github.com/amol-/depot/actions/workflows/run-tests.yml\n\n.. image:: https://coveralls.io/repos/amol-/depot/badge.png?branch=master\n    :target: https://coveralls.io/r/amol-/depot?branch=master \n\n.. image:: https://img.shields.io/pypi/v/filedepot.svg\n   :target: https://pypi.python.org/pypi/filedepot\n\nDEPOT is a framework for easily storing and serving files in\nweb applications on Python2.6+ and Python3.2+.\n\nDEPOT supports storing files in multiple backends, like:\n\n* Local Disk\n* In Memory (for tests)\n* On GridFS\n* On Amazon S3 (or compatible services)\n* On Google Cloud Storage\n\nand integrates with database by providing files\nattached to your **SQLAlchemy** or **Ming/MongoDB** models\nwith respect to transactions behaviours (files are rolled back too).\n\nInstalling\n----------\n\nInstalling DEPOT can be done from PyPi itself by installing the ``filedepot`` distribution::\n\n    $ pip install filedepot\n\nGetting Started\n---------------\n\nTo start using Depot refer to `Documentation <https://depot.readthedocs.io/en/latest/>`_\n\nDEPOT was `presented at PyConUK and PyConFR <http://www.slideshare.net/__amol__/pyconfr-2014-depot-story-of-a-filewrite-gone-wrong>`_ in 2014\n\nstandalone\n~~~~~~~~~~\n\nHere is a simple example of using depot standalone to store files on MongoDB::\n\n    from depot.manager import DepotManager\n\n    # Configure a *default* depot to store files on MongoDB GridFS\n    DepotManager.configure('default', {\n        'depot.backend': 'depot.io.gridfs.GridFSStorage',\n        'depot.mongouri': 'mongodb://localhost/db'\n    })\n\n    depot = DepotManager.get()\n\n    # Save the file and get the fileid\n    fileid = depot.create(open('/tmp/file.png'))\n\n    # Get the file back\n    stored_file = depot.get(fileid)\n    print stored_file.filename\n    print stored_file.content_type\n\nmodels\n~~~~~~\n\nOr you can use depot with SQLAlchemy to store attachments::\n\n    from depot.fields.sqlalchemy import UploadedFileField\n    from depot.fields.specialized.image import UploadedImageWithThumb\n\n\n    class Document(Base):\n        __tablename__ = 'document'\n\n        uid = Column(Integer, autoincrement=True, primary_key=True)\n        name = Column(Unicode(16), unique=True)\n        content = Column('content_col', UploadedFileField)  # plain attached file\n\n        # photo field will automatically generate thumbnail\n        photo = Column(UploadedFileField(upload_type=UploadedImageWithThumb))\n\n\n    # Store documents with attached files, the source can be a file or bytes\n    doc = Document(name=u'Foo',\n                content=b'TEXT CONTENT STORED AS FILE',\n                photo=open('/tmp/file.png'))\n    DBSession.add(doc)\n    DBSession.flush()\n\n    # DEPOT is session aware, commit/rollback to keep or delete the stored files.\n    DBSession.commit()\n\nChangeLog\n---------\n\n0.11.0\n~~~~~~\n\n- Officially support Python 3.12\n- Addressed deprecation of ``Image.ANTIALIAS`` in Pillow, ``Image.LANCZOS`` is used instead\n- TurboGears2 is no longer needed to run tests\n- Depot is now compatible with ``multipart`` module or other replacements of ``cgi.FieldStorage``\n- Fixed an open file leak in ``UploadedImageWithThumb``\n- Fixed an open file leak in ``WithThumbnailFilter``\n\n0.10.0\n~~~~~~\n\n- Added support for Google Cloud Storage\n- Fixed ACL issues with S3\n- Deprecated boto2 backend, use boto3\n- Added support for performing backups by copying to another storage\n\n0.9.0\n~~~~~\n\n- Support for SQLAlchemy 1.4 and 2.0\n- Support for SQLAlchemy objects deleted with ``.delete(synchronize_session=\"fetch\")``\n- Tests migrated to ``unittest``\n\n0.8.0\n~~~~~\n\n- Replaced ``unidecode`` dependency with ``anyascii`` to better cope with MIT License.\n\n0.7.1\n~~~~~\n\n- Fix a bug in AWS-S3 support for unicode filenames.\n\n0.7.0\n~~~~~\n\n- Support for ``storage_class`` option in ``depot.io.boto3.S3Storage`` backend. Detaults to ``STANDARD``\n\n0.6.0\n~~~~~\n\n- Officially support Python 3.7\n- Fix DEPOT wrongly serving requests for any url that starts with the mountpoint. (IE: ``/depotsomething`` was wrongly served for ``/depot`` mountpoint)\n- In SQLAlchemy properly handle deletion of objects deleted through ``Relationship.remove`` (IE: ``parent.children.remove(X)``)\n- In SQLAlchemy properly handle entities deleted through ``cascade='delete-orphan'``\n\n0.5.2\n~~~~~\n\n- Fixed an *start_response called a second time without providing exc_info* error with storages supporting plublic urls\n\n\n0.5.1\n~~~~~\n\n- URLs generated by ``DepotMiddleware`` are now guaranteed to be plain ascii\n- [Breaking change]: Bucket existance with S3 storages should now be more reliable when the\n  bucket didn't already exist, but it requires an additional AWS policy: `s3:ListAllMyBuckets` that wasn't required on 0.5.0\n\n0.5.0\n~~~~~\n\n- ``depot.io.boto3.S3Storage`` now provides support for accessing S3 with ``boto3``.\n  The previously existing ``depot.io.awss3.S3Storage`` can still be used to store\n  files on S3 using ``boto``.\n- SQLAlchemy integration now handles deletion of files on rollback when session\n  is not flushed. Previously flushing the session was required before a rollback too.\n- It is now possible to run tests through ``tox`` and build docs through ``tox -e docs``\n- DEPOT is now tested against Python 3.6\n\n0.4.1\n~~~~~\n\n- Fixed installation error on non-UTF8 systems\n- Improved support for polymorphic subtypes in SQLAlchemy\n\n0.4.0\n~~~~~\n\n- Support for Python 3.5\n- Fixed ``Content-Disposition`` header for filenames including a comma\n\n0.3.2\n~~~~~\n\n- ``MemoryFileStorage`` now accepts any option, for easier testing configuration\n\n0.3.1\n~~~~~\n\n* Fixed ``Content-Disposition`` header when serving from S3 directly\n* Fixed size of SQLAlchemy field on Oracle (was bigger than the allowed maximum)\n\n0.3.0\n~~~~~\n\n- ``MemoryFileStorage`` provides in memory storage for files. This is meant to provide a\n  convenient way to speed up test suites and avoid fixture clean up issues.\n- S3Storage can now generate public urls for private files (expire in 1 year)\n- Files created from plain bytes are now named \"unnamed\" instead of missing a filename.\n\n0.2.1\n~~~~~\n\n- ``S3Storage`` now supports the ``prefix`` option to store files in a subpath\n\n0.2.0\n~~~~~\n\n- Storages now provide a ``list`` method to list files available on the store (This is not meant to be used to retrieve files uploaded by depot as it lists all the files).\n- ``DepotExtension`` for Ming is now properly documented\n\n0.1.2\n~~~~~\n\n- It is now possible to use multiple ``WithThumbnailFilter`` to generate multiple thumbnails\n  with different resolutions.\n- Better documentation for MongoDB ``UploadedFileProperty``\n\n0.1.1\n~~~~~\n\n- Fixed a bug with Ming support when acessing ``UploadedFileProperty`` as a class property\n- Improved support for DEPOT inside TurboGears admin when using MongoDB\n\n0.1.0\n~~~~~\n\n- Added ``DepotManager.alias`` to configure aliases to storage.\n  This allows easy migration from one storage to another by switching where the alias points.\n- Now ``UploadedFileField`` permits to specify ``upload_storage`` to link a Model Column to a specific storage.\n- Added ``policy`` and ``encrypt_key`` options to `S3Storage` to upload private and encrypted files.\n\n0.0.6\n~~~~~\n\n- Added `host` option to `S3Storage` to allow using providers different from *AWS*.\n\n0.0.5\n~~~~~\n\n- Added `FileIntent` to explicitly provide `content_type` and `filename` to uploaded content.\n\n0.0.4\n~~~~~\n\n- Added Content-Disposition header with original filename in WSGI middleware\n\n0.0.3\n~~~~~\n\n- Work-Around for issue with `wsgi.file_wrapper` provided by Waitress WSGI Server\n\n0.0.2\n~~~~~\n\n- Official Support for AWS S3 on Python3\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Toolkit for storing files and attachments in web applications",
    "version": "0.11.0",
    "project_urls": {
        "Homepage": "https://github.com/amol-/depot"
    },
    "split_keywords": [
        "storage",
        "files",
        "s3",
        "gridfs",
        "mongodb",
        "aws",
        "sqlalchemy",
        "wsgi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "19760128b0d2958b81a5f9738680af5b3ef9cdd31513e833ecbd67dcb3fa09f1",
                "md5": "4e1191c59ef88050094eb50f47aff3fe",
                "sha256": "26d4ca647383f08fb4dbdba4d1f92bd699a0dd1c230d90cf0766eb3b6aadc195"
            },
            "downloads": -1,
            "filename": "filedepot-0.11.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4e1191c59ef88050094eb50f47aff3fe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 43153,
            "upload_time": "2024-02-22T21:48:13",
            "upload_time_iso_8601": "2024-02-22T21:48:13.390613Z",
            "url": "https://files.pythonhosted.org/packages/19/76/0128b0d2958b81a5f9738680af5b3ef9cdd31513e833ecbd67dcb3fa09f1/filedepot-0.11.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-22 21:48:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "amol-",
    "github_project": "depot",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "filedepot"
}
        
Elapsed time: 0.24029s