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

4
2个回答

0

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'

请问我们应该在哪里以及如何添加mixin?非常感谢您的指引。 - cvipul

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接