Django - 适用于S3的文件浏览器的替代品

时间:2013-03-06 15:13:13

标签: django amazon-s3 boto django-storage django-filebrowser

Django Filebrowserstorage services不兼容。

Django Filer上找到的{p> Django Packages似乎是一个不错的选择,但它对存储后端的支持似乎不完整。

我想知道Django的文件浏览器的其他替代方案是什么,它与S3很好地集成。

2 个答案:

答案 0 :(得分:0)

我在我的项目中使用了https://github.com/bradleyg/django-s3direct。它工作得很好。它也列在你提到的Django Packages网站上。

答案 1 :(得分:0)

当您加入S3BotoStorageMixin时,此程序包应该能够在S3上运行。

from filebrowser.storage import S3BotoStorageMixin
from storages.backends.s3boto import S3BotoStorage


class CustomS3BotoStorage(S3BotoStorageMixin, S3BotoStorage):
    def path(self, name):
        # Workaround for django-filebrowser, which requests full_path on uploaded files.
        # The operation is not needed at all, since no chmod happens afterwards.
        return self.url(name)

    def isfile(self, name):
        # Hacky performance optimization for filebrowser.
        # The original isdir() method is really inefficient.
        if '.' in name:
            return True
        return super().isfile(name)

settings.py

DEFAULT_FILE_STORAGE = 'myproject.lib.storages.CustomS3BotoStorage'