在Django Packages上找到的Django Filer似乎是一个不错的选择,但它对存储后端的支持似乎不完整。
我想知道与 S3 很好地集成的 Django 文件浏览器的其他替代方案。
在Django Packages上找到的Django Filer似乎是一个不错的选择,但它对存储后端的支持似乎不完整。
我想知道与 S3 很好地集成的 Django 文件浏览器的其他替代方案。
我在我的项目中使用了https://github.com/bradleyg/django-s3direct 。效果很好。它也列在您提到的 Django Packages 站点上。
当你包含 时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'